Tuesday, September 1, 2015

Response 429 for SharePoint REST API

Recently I got to work on an instance where it continuously made many REST API calls to SharePoint within a limited amount of time. It was a set of workflows where around 2000 workflows started at a limited amount of time. To make things worse, all these workflows were started from the same user. 

The response 429 is for Too Many Requests.



This is something common with the REST services. It returns the 429 code when a single user make too many requests within a single time. 

The real reason behind the 429 error is exceeding the throttling limit. In many sources it is mentioned that this happens when SharePoint keeps receiving more than a request per second for a continuous amount of time. But REST API is just one way of exceeding the throttling limit for the user. The CSOM which uses the same endpoint is the next most famous.

Therefore when you can suspect your code (in my case, the workflow) might cause exceeding of throttling limit, you might consider certain precautions that can help you get through with that. 

Having multiple users start the workflows fixed the issue for me. But the solution might not be the best appropriate for you. 

A detailed article on SharePoint Online resource throttling is available with MSDN. These basics must be the same for SharePoint Server on premise too. 

4 comments:

  1. Hi Malin!

    Thank you for this post. I have a weird situation: I get a 429, but it doesn't say "Too many requests." The response contains no such message. Or any other. Any hints on that?

    ReplyDelete
    Replies
    1. Standard HTTP 429 is the code for Too Many Requests. Therefore it shall be. One way you can verify is by monitoring the traffic using Fiddler.

      Delete
    2. Well, that was a speedy reply! What puzzles me is that in some situations I get a 429, with a "Too many requests" in its response, but I also get a 429 without any message in the response body.

      Delete