Graph api createUploadSession returns 401 on uploadUrl

Kemal Yildirim 70 Reputation points
2025-04-17T08:20:45.0266667+00:00

Hello,

This code has been running for 2 years, now it started to fail after we paid an unpaid subscription.
not sure it's because of that but here we are.

I am using a registered application to get the bearer token for this

after making a post request to this

"https://graph.microsoft.com/v1.0/users/{userPrinciple}/messages/{messageId}/attachments/createUploadSession"

I am getting back the response with the uploadUrl to put the chunks of the attachment

and using it to upload the chunks like

using (var httpRequest = new HttpRequestMessage(HttpMethod.Put, uploadUrl));> httpRequest.Content = new ByteArrayContent(body);> httpRequest.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

httpRequest.Content.Headers.Add("Content-Length", $"{processingByteSize}"); httpRequest.Content.Headers.Add("Content-Range", $"bytes {completedByteSize}-{completedByteSize + processingByteSize - 1}/{attachmentBytes.Length}"); var response = await _client.SendAsync(httpRequest).ConfigureAwait(false);

but then I am getting Unauthorized response

Any luck what could be the reason?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,487 questions
{count} votes

Accepted answer
  1. TA 135 Reputation points
    2025-04-18T19:16:34.8066667+00:00

    We finally received both confirmation from Microsoft of the issue as well as an update on the fix in our support ticket:

    The cause of the issue has been identified, and a fix has been rolled out. It is expected to be fully deployed by early next week. We apologize for the disruption this has caused.

    4 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Mark Cockburn 26 Reputation points
    2025-04-18T18:23:27.23+00:00

    My Service Provider escalated to Microsoft quickly for me.

    It is a known issue for which they are currently working on a fix.

    2 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.