sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SharePoint returns TOO MANY REQUESTS for 401 HTTP code

Open Vasyl18 opened this issue 8 years ago • 7 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

I develop simple application for fetching data in SharePoint sites. I use requests from SharePoint REST API for getting SharePoint Sites info (both for Team Sites and Communication Sites). Also I use such API for getting info about files and folders in SharePoint document libraries.

Expected or Desired Behavior

Sometimes I get throttling responses from Microsoft with 429 HTTP code and
"429 TOO MANY REQUESTS" message in reply body.

Observed Behavior

But recently I noticed strange behavior: "429 TOO MANY REQUESTS" message returned in reply body but HTTP status code is 401 (which status for UNAUTHORIZED request). However I handle 401 HTTP status code in different way and this totally break the logic of my service and 401 HTTP status code in general.

I think it's not normal behavior, is it? How can I determine if 401 HTTP status code states for throttling of for unauthorized request? Straightforward reply body parsing is not a good approach as I think.

Vasyl18 avatar Sep 14 '18 15:09 Vasyl18

Just to help diagnose this, what REST end point were you calling that returned a 401?

patmill avatar Sep 14 '18 18:09 patmill

I can see this problem for requests related to all REST endpoints no meter if I work with files and folders or with lists: e. g. I can get this "bad" reply when I fetch folders in doc lib using this endpoints http://<site_url>/_api/web/GetFolderByServerRelativeUrl(<folder_url>) http://<site_url>/_api/web/GetFolderById(<folder_guid>)/Folders

Vasyl18 avatar Sep 17 '18 15:09 Vasyl18

I see this problem more often than before. Any progress on this?

Vasyl18 avatar Sep 24 '18 11:09 Vasyl18

@Vasyl18

For 429 error, it definitely is throttling issue. You can have look throttling docs

From developer point of view. The reason you have received 401 error might be you have too many 429 request, and your IP is temporarily blocked by Server. ( That's my guess, because I've read some article online)

Each server has dynamic monitored and each server contains few tenants. For example we have 3 tenants in current Server, and 2 tenants don't have that much request atm, and you will have higher trigger point to retrieve 429 error than the normal time. However, if other 2 tenants are calling REST APIs, the server will dynamic distribute resources to other tenants. If currently you are still having a lot APIs request, the server will block your request for a while than unblock it later when it doesn't have too much pressure.

I forgot original url the article I read, but hopefully you can understand my example from my understanding in the article.

I think you should optimize your code to avoid getting throttled or blocked in SharePoint Online. Or you can contact MSFT to add your tenant in white board to get more API calling usage.

TheMiao avatar Oct 24 '18 11:10 TheMiao

Good afternoon!, is there any update on this? We are getting more 401 errors now, and the only way to past through them is to wait a while and retry

frodale avatar Nov 13 '20 11:11 frodale

This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open or submit a new issue.

ghost avatar Dec 30 '21 14:12 ghost

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

ghost avatar Jan 06 '22 18:01 ghost