4
votes

I've written a console app, that will be used to upload files to an Office 365 Unified Group. I'm using the Microsoft Graph API to get a reference to the drive under the group, and then upload files. I am using the Microsoft.IdentityModel.Clients.ActiveDirectory NuGet package for Authentication. This application needs to upload several thousand files, and I believe that I'm encountering some throttling issues.

I am able to upload around 4000 files without any issues, but after that I begin to get 401 "Unauthorized" responses. At first I thought it was a token expiration issue, but I changed my code to get a brand new token if a 401 is encountered. I didn't initially suspect throttling issues, because I am not getting a 429 reponse error code (see: https://github.com/OfficeDev/microsoft-graph-docs/blob/master/content/overview/errors.md).

Is it possible that too many requests to the Microsoft Graph API in some period of time could result in 401 Unauthorized error response messages?

I'm making the upload requests sequentially (not in parallel), and I've added a 1 second pause between each request.

1
Hi Camden. Can you provide the response headers for one of these failed requests? They should include a response-id header that I can use to see what's going on with that request so we can get a solution for you. - Ryan Gregg
Hey Ryan, Thank you for your prompt response. I was able to upload 3916 files, along with 8307 directories for 12223 total items. The total size of the upload before the failure was 2.46GB. In an answer below, I will post the response from the Microsoft Graph API, because it is too large for a comment. I suspect the issue is related to either #items, or total storage usage. I am just surprised that the error is a 401, instead of a 429, 507, or 509. - Camden Reslink

1 Answers

0
votes

here are my response headers:

StatusCode: 401,  
ReasonPhrase: 'Unauthorized',  
Version: 1.1,  
Content: System.Net.Http.StreamContent,  
Headers:  
{  
    Transfer-Encoding: chunked  
    request-id: 19e991f2-6687-4f39-9f3e-1fe80f110ee4  
    client-request-id: 19e991f2-6687-4f39-9f3e-1fe80f110ee4  
    x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West US","Slice":"SliceB","ScaleUnit":"000","Host":"AGSFE_IN_2","ADSiteName":"WST"}}  
    OutBoundDuration: 71.3045  
    Duration: 789.1043  
    Cache-Control: private  
    Date: Tue, 05 Jan 2016 01:58:15 GMT  
    Server: Microsoft-IIS/8.5  
    X-Powered-By: ASP.NET  
    Content-Type: application/json  
}