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

Symbol for "not absolutely continuous" in Latex

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

Multiple computers 1 minecraft

How did Lefschetz do mathematics without hands?

Should I report a leak of confidential HR information?

Single level file directory

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

Put my student loan in parents’ second mortgage - help?

How is this practical and very old scene shot?

What does grep -v "grep" mean and do?

Could human civilization live 150 years in a nuclear-powered aircraft carrier colony without resorting to mass killing/ cannibalism?

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

Movie in a trailer park named Paradise and a boy playing a video game then being recruited by aliens to fight in space

What game is this character in the Pixels movie from?

What is "oversubscription" in Networking?

Is it okay to fade a human face just to create some space to place important content over it?

Why were the first airplanes "backwards"?

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

Can I travel from Germany to England alone as an unaccompanied minor?

Adjective for 'made of pus' or 'corrupted by pus' or something of something of pus

Can Aziraphale and Crowley actually become native?

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

Who are these Discworld wizards from this picture?

Different budgets within roommate group



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 8 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 7 hours ago

























                answered 7 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

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її