Apex REST API - Unable to set StatusCode to 429unable to create user with REST api emailApex REST Web Service: Unexpected parameter encountered during deserializationMessageDefinitionSends Rest API successful response but never sends emailUploading a file to Chatter - REST APIWhen generate Pdf from trigger, getting Error ( HttpResponse[Status=Bad Request, StatusCode=400]),Allow Access origin Issue With Rest Api For Patch MethodStatus=Bad Request, StatusCode=400 on rest api callSalesforce REST API CallREST API call via Postman to read JourneyMarketing Cloud REST API “Not Authorized” error in Postman

Why was Mal so quick to drop Bester in favour of Kaylee?

Company threatening to call my current job after I declined their offer

How can my story take place on Earth without referring to our existing cities and countries?

What's the safest way to inform a new user of their password on an invite-only website?

Why were the first airplanes "backwards"?

Buliding a larger matrix from a smaller one

Does a return economy-class seat between London and San Francisco release 5.28 t of CO2e?

Does the Pi 4 resolve the Ethernet+USB bottleneck issue of past versions?

In native German words, is Q always followed by U, as in English?

Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?

How would an order of Monks that renounce their names communicate effectively?

Graph problems as integer programs

How to organize members in a struct to waste least space on alignment?

Is there a canon reason why Klingon and Romulan vessels are so similar in shape?

Multiple computers 1 minecraft

Are all commands with an optional argument fragile?

Why does the same classical piece sound like it's in a different key in different recordings?

What's the easiest way for a whole party to be able to communicate with a creature that doesn't know Common?

How hard is it to sell a home which is currently mortgaged?

Golf the smallest circle!

Can an editor review manuscript without sending to reviewers?

What's the rule for a natural 20 on a Perception check?

What exactly did Ant-Man see that made him say that their plan worked?

Military Uniform of Great Grandfather



Apex REST API - Unable to set StatusCode to 429


unable to create user with REST api emailApex REST Web Service: Unexpected parameter encountered during deserializationMessageDefinitionSends Rest API successful response but never sends emailUploading a file to Chatter - REST APIWhen generate Pdf from trigger, getting Error ( HttpResponse[Status=Bad Request, StatusCode=400]),Allow Access origin Issue With Rest Api For Patch MethodStatus=Bad Request, StatusCode=400 on rest api callSalesforce REST API CallREST API call via Postman to read JourneyMarketing Cloud REST API “Not Authorized” error in Postman






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am trying to set the status code to 429 for Too many request using the code below:



if(Limits.getQueries() < Limits.getLimitQueries())
upsert UpdateData;

else if((Limits.getQueries() >= Limits.getLimitQueries()))

RestContext.response.statusCode = 429;
UpdateError[] err = new UpdateError[]
new UpdateReturnError(UpdateData.Id, 'Too many Requests', 'Error updating MessageID ' + msg.MessageId)
;
RestContext.response.responseBody = Blob.valueOf(JSON.serialize(err));
RestContext.response.addHeader('Content-Type', 'application/json');
break;

}


I am getting the following error in the raw response:



enter image description here



Can someone help me out with this?










share|improve this question







New contributor



John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    I am trying to set the status code to 429 for Too many request using the code below:



    if(Limits.getQueries() < Limits.getLimitQueries())
    upsert UpdateData;

    else if((Limits.getQueries() >= Limits.getLimitQueries()))

    RestContext.response.statusCode = 429;
    UpdateError[] err = new UpdateError[]
    new UpdateReturnError(UpdateData.Id, 'Too many Requests', 'Error updating MessageID ' + msg.MessageId)
    ;
    RestContext.response.responseBody = Blob.valueOf(JSON.serialize(err));
    RestContext.response.addHeader('Content-Type', 'application/json');
    break;

    }


    I am getting the following error in the raw response:



    enter image description here



    Can someone help me out with this?










    share|improve this question







    New contributor



    John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      1












      1








      1








      I am trying to set the status code to 429 for Too many request using the code below:



      if(Limits.getQueries() < Limits.getLimitQueries())
      upsert UpdateData;

      else if((Limits.getQueries() >= Limits.getLimitQueries()))

      RestContext.response.statusCode = 429;
      UpdateError[] err = new UpdateError[]
      new UpdateReturnError(UpdateData.Id, 'Too many Requests', 'Error updating MessageID ' + msg.MessageId)
      ;
      RestContext.response.responseBody = Blob.valueOf(JSON.serialize(err));
      RestContext.response.addHeader('Content-Type', 'application/json');
      break;

      }


      I am getting the following error in the raw response:



      enter image description here



      Can someone help me out with this?










      share|improve this question







      New contributor



      John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I am trying to set the status code to 429 for Too many request using the code below:



      if(Limits.getQueries() < Limits.getLimitQueries())
      upsert UpdateData;

      else if((Limits.getQueries() >= Limits.getLimitQueries()))

      RestContext.response.statusCode = 429;
      UpdateError[] err = new UpdateError[]
      new UpdateReturnError(UpdateData.Id, 'Too many Requests', 'Error updating MessageID ' + msg.MessageId)
      ;
      RestContext.response.responseBody = Blob.valueOf(JSON.serialize(err));
      RestContext.response.addHeader('Content-Type', 'application/json');
      break;

      }


      I am getting the following error in the raw response:



      enter image description here



      Can someone help me out with this?







      apex rest-api apexrest rest-service






      share|improve this question







      New contributor



      John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share|improve this question







      New contributor



      John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share|improve this question




      share|improve this question






      New contributor



      John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      asked 9 hours ago









      John MJohn M

      133 bronze badges




      133 bronze badges




      New contributor



      John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      New contributor




      John M is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes


















          6














          429 Too Many Requests is not an appropriate status to return from Apex that is processing a REST request, and so presumably that's why the server prevents you from doing so. The relevent RFC indicates that this response is for rate-limiting, ie, the number of HTTP requests received from a single client in a given amount of time:




          The 429 status code indicates that the user has sent too many
          requests in a given amount of time ("rate limiting").



          The response representations SHOULD include details explaining the
          condition, and MAY include a Retry-After header indicating how long
          to wait before making a new request.




          Each REST request will be a separate Apex transaction, and the # of SOQL queries issued is a per-transaction limit. So exceeding that limit would never be because too many calls to your endpoint had come from a single client in a given period of time.



          The documentation for the RestResponse class lists the acceptable values for the statusCode property, and 429 is not included.



          This should probably be a 200 response, or perhaps a 500. You're successfully receiving and processing the HTTP request. It's just that the result of that request exceeded a limit, but that limit is at a layer much further down than the HTTP server.






          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "459"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );






            John M is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f267246%2fapex-rest-api-unable-to-set-statuscode-to-429%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            6














            429 Too Many Requests is not an appropriate status to return from Apex that is processing a REST request, and so presumably that's why the server prevents you from doing so. The relevent RFC indicates that this response is for rate-limiting, ie, the number of HTTP requests received from a single client in a given amount of time:




            The 429 status code indicates that the user has sent too many
            requests in a given amount of time ("rate limiting").



            The response representations SHOULD include details explaining the
            condition, and MAY include a Retry-After header indicating how long
            to wait before making a new request.




            Each REST request will be a separate Apex transaction, and the # of SOQL queries issued is a per-transaction limit. So exceeding that limit would never be because too many calls to your endpoint had come from a single client in a given period of time.



            The documentation for the RestResponse class lists the acceptable values for the statusCode property, and 429 is not included.



            This should probably be a 200 response, or perhaps a 500. You're successfully receiving and processing the HTTP request. It's just that the result of that request exceeded a limit, but that limit is at a layer much further down than the HTTP server.






            share|improve this answer





























              6














              429 Too Many Requests is not an appropriate status to return from Apex that is processing a REST request, and so presumably that's why the server prevents you from doing so. The relevent RFC indicates that this response is for rate-limiting, ie, the number of HTTP requests received from a single client in a given amount of time:




              The 429 status code indicates that the user has sent too many
              requests in a given amount of time ("rate limiting").



              The response representations SHOULD include details explaining the
              condition, and MAY include a Retry-After header indicating how long
              to wait before making a new request.




              Each REST request will be a separate Apex transaction, and the # of SOQL queries issued is a per-transaction limit. So exceeding that limit would never be because too many calls to your endpoint had come from a single client in a given period of time.



              The documentation for the RestResponse class lists the acceptable values for the statusCode property, and 429 is not included.



              This should probably be a 200 response, or perhaps a 500. You're successfully receiving and processing the HTTP request. It's just that the result of that request exceeded a limit, but that limit is at a layer much further down than the HTTP server.






              share|improve this answer



























                6












                6








                6







                429 Too Many Requests is not an appropriate status to return from Apex that is processing a REST request, and so presumably that's why the server prevents you from doing so. The relevent RFC indicates that this response is for rate-limiting, ie, the number of HTTP requests received from a single client in a given amount of time:




                The 429 status code indicates that the user has sent too many
                requests in a given amount of time ("rate limiting").



                The response representations SHOULD include details explaining the
                condition, and MAY include a Retry-After header indicating how long
                to wait before making a new request.




                Each REST request will be a separate Apex transaction, and the # of SOQL queries issued is a per-transaction limit. So exceeding that limit would never be because too many calls to your endpoint had come from a single client in a given period of time.



                The documentation for the RestResponse class lists the acceptable values for the statusCode property, and 429 is not included.



                This should probably be a 200 response, or perhaps a 500. You're successfully receiving and processing the HTTP request. It's just that the result of that request exceeded a limit, but that limit is at a layer much further down than the HTTP server.






                share|improve this answer















                429 Too Many Requests is not an appropriate status to return from Apex that is processing a REST request, and so presumably that's why the server prevents you from doing so. The relevent RFC indicates that this response is for rate-limiting, ie, the number of HTTP requests received from a single client in a given amount of time:




                The 429 status code indicates that the user has sent too many
                requests in a given amount of time ("rate limiting").



                The response representations SHOULD include details explaining the
                condition, and MAY include a Retry-After header indicating how long
                to wait before making a new request.




                Each REST request will be a separate Apex transaction, and the # of SOQL queries issued is a per-transaction limit. So exceeding that limit would never be because too many calls to your endpoint had come from a single client in a given period of time.



                The documentation for the RestResponse class lists the acceptable values for the statusCode property, and 429 is not included.



                This should probably be a 200 response, or perhaps a 500. You're successfully receiving and processing the HTTP request. It's just that the result of that request exceeded a limit, but that limit is at a layer much further down than the HTTP server.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 8 hours ago

























                answered 9 hours ago









                Thomas TaylorThomas Taylor

                2,87313 silver badges33 bronze badges




                2,87313 silver badges33 bronze badges




















                    John M is a new contributor. Be nice, and check out our Code of Conduct.









                    draft saved

                    draft discarded


















                    John M is a new contributor. Be nice, and check out our Code of Conduct.












                    John M is a new contributor. Be nice, and check out our Code of Conduct.











                    John M is a new contributor. Be nice, and check out our Code of Conduct.














                    Thanks for contributing an answer to Salesforce Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f267246%2fapex-rest-api-unable-to-set-statuscode-to-429%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

                    Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

                    19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу