Microsoft Graph API, corrupted files

887 Views Asked by At

I am using this document to upload excel files to OneDrive https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online.

The API call in Postman is: https://graph.microsoft.com/v1.0/me/drive/root:/FolderA/cn.xlsx:/content?

Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

The issue is that the file got uploaded, but it is always being corrupted. The reason I believe is that the file is being convert to text file first, and then convert back to excel file due to the file extension (xlsx).

Does anyone know how I can get around this issues? Thank you very much.

Postman's snippet

Postman's snippet 2

1

There are 1 best solutions below

0
On

Try to put 'text/plain' in content-type when you upload the bytes. This resolved my problem.