Upload an excel file using graph API

Gopi, Radhika 61 Reputation points
2021-06-10T01:23:19.167+00:00

Hi @MichaelHan-MSFT
I would like to upload an excel file using Graph API. When I create using the URL "https://graph.microsoft.com/v1.0/sites/<tenantID followed by the other ID's>/drive/root:/test/FileNew.xlsx:/content:
it creates the file, but when trying to open it the following "Couldn't open the workbook" error occurs:

![103983-image.png][1]

Any help is appreciated.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,582 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,621 questions
Excel Management
Excel Management
Excel: A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.Management: The act or process of organizing, handling, directing or controlling something.
1,640 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-06-10T06:40:41.673+00:00

    Hi @Gopi, Radhika ,

    In request body, it should be the binary stream of the file to be uploaded.

    In Postman, we could choose binary type in body. Then select the file you want to upload. As the below picture shows:

    104030-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.


1 additional answer

Sort by: Most helpful
  1. Jagan 21 Reputation points
    2022-01-04T18:23:29.207+00:00

    @MichaelHan-MSFT , I'm running into similar kind of issue without using Postman. When i use Postman everything works fine, but when using it from my application, the pdfs, docs, ppts, images are coming as blank.
    I'm converting a file from base64 to binary (using atob function) and sending that binary data in the body.

    Language: AngularJS

    Any help will be really appreciated.

    Thanks in Advance!!!