Microsoft Graph - CreateUploadSession, Unauthorized (401)

Moses Thompson 0 Reputation points
2025-12-18T22:53:14.1533333+00:00

Hello,

I am working with Microsoft Graph. I am calling the API CreateUploadSession. The API is successfully providing an upload URL based on the authorization token I provide. To prove that I understand the process, I use postman to upload text data. This process is successful. Specifically, with postman, I can call CreateUploadSession with authentication token obtain an upload URL and successfully upload to the URL provided.

However, I have a microcontroller doing the same process but receives a 401(unauthorized) error when trying to upload data to the provided uploadURL. Specifically, with the microcontroller, I call the CreateUploadSession with an authorization token, obtain a uploadURL and attempt to upload simple text data and I received a 401 (unauthorized) error.

Can anyone provide insight for what the issue is?

Thanks

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-18T22:53:27.0566667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The 401 Unauthorized error you are encountering with your microcontroller when trying to upload data to the provided upload URL could be due to several reasons:

    1. Token Validity: Ensure that the authorization token you are using in the microcontroller is valid and has not expired. A common cause for a 401 error is an invalid or expired token. You can verify the token by checking if it works in Postman.
    2. Authorization Header: When making the PUT request to upload data, ensure that you are not including the Authorization header. According to the Microsoft Graph documentation, the Authorization header should only be sent when creating the upload session, not during the upload itself. This could lead to a 401 error if included incorrectly.
    3. Network Configuration: If your microcontroller is operating in a different network environment than Postman, ensure that there are no network restrictions or firewall rules that might be blocking the request.
    4. Content-Type Header: Make sure that you are setting the correct Content-Type header when uploading data. If the content type is not set correctly, it might lead to authorization issues.
    5. Payload Size: Ensure that the payload you are trying to upload does not exceed the maximum allowed size for a single request, which is 10 MB. If you are splitting the upload into multiple parts, make sure that each part is within the acceptable size limits.

    By checking these aspects, you should be able to identify the cause of the 401 error in your microcontroller's upload process.


    References:

    0 comments No comments

Your answer

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