Upload a large excel file using createuploadsession Graph API

Gopi, Radhika 61 Reputation points
2021-06-14T23:59:12.443+00:00

Hi @MichaelHan-MSFT ,
I am trying to upload a large excel file using the createuploadsession option in Graph API via Postman. Below are the settings that I selected:

URL: https://graph.microsoft.com/v1.0/sites/<siteID>tenantID>/drive/root/test/testing.xlsx:/createUploadSession

105593-image.png

I get the success message but no Upload URL is returned. May I know if I am missing something or any details are incorrect? Also can you tell where I should specify the drive file name(source file) and the Sharepoint filename(destination file)?

Microsoft 365 and Office SharePoint For business Windows
Microsoft 365 and Office Excel For business Windows
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,126 Reputation points
    2021-06-15T02:29:54.217+00:00

    Hi @Gopi, Radhika ,

    The createuploadsession request doesn't require file in the body, just choose none for the request. We would get the upload URL in the response body. As the below picture shows.

    POST https://graph.microsoft.com/v1.0/sites/{siteID}/drive/root:/test/testing.xlsx:/createUploadSession  
    

    105609-image.png

    Then we could use the Upload URL to upload the large file.

    put {upload URL returned}  
    

    In the body, choose the file. ThenAdd two headers Content-Length and Content-Range for the request.

    Content-Length : {fileSize in bytes}
    Content-Range: bytes 0-{fileSize-1}/{fileSize}

    For example:

    105634-image.png
    105559-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    If the response is helpful, please click "Accept Answer" and upvote it.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Gopi, Radhika 61 Reputation points
    2021-06-15T22:26:50.433+00:00

    It worked. Thanks for the answer.

    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.