Search code examples
c#onedrivemicrosoft-graph-api

Are chunked uploads blocked for personal accounts in the Microsoft Graph API?


I tested the .NET SDK code from the /MIchaelMainer/working branch, and it worked fine for work accounts.

However, it fails ("Authentication failed") for personal accounts (even small files).

The documentation about resumable uploads doesn't say anything about this being a work accounts feature only.

Perhaps it is? Or is there a bug? If it is a bug, I don't see in the code where it could be, because the single difference is the account type.

(related: https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/61)


Solution

  • Thanks, Ryan.

    In UploadChunkRequest.cs => SendRequestAsync(), I did this update (line commented):

            using (var request = this.GetHttpRequestMessage())
            {
                //await this.Client.AuthenticationProvider.AuthenticateRequestAsync(request).ConfigureAwait(false);
    
                request.Content = new StreamContent(stream);
                request.Content.Headers.ContentRange =
                    new ContentRangeHeaderValue(this.RangeBegin, this.RangeEnd, this.TotalSessionLength);
                request.Content.Headers.ContentLength = this.RangeLength;
    
                return await this.Client.HttpProvider.SendAsync(request, completionOption, cancellationToken).ConfigureAwait(false);
            }
    

    Now the chunked upload works fine for personal and business accounts!

    Michael will update the code in GitHub, I think?

    What I'm still unable to do is upload to a shared folder.