Graph API small file upload success but docx won't open in browser, error in desktop app

asked 2022-04-06T01:10:49.323+00:00

Hi, I am using Zoho Deluge to download a file from Box using Box API then upload to Sharepoint using Graph API.

The file uploads but gets corrupted. Works fine in Postman using Binary body option.

In word online I get:


And in desktop Word:


This is the script I've written. The Graph response looks normal:

// Upload file to Sharepoint
graph_header = Map();
graph_header.put("Authorization","Bearer " + graph_access_token);
graph_body = Map();
graph_upload_file = invokeurl
url :"!cBfsvaQVPlqf5An1C82RbwVjjG22-Qo9S4bs-PPMe/items/root:/" + file_name + ":/content"
type :PUT
info graph_upload_file;

Any help would be appreciated. Thanks!

Microsoft Graph Files API
Microsoft Graph Files API
A Microsoft API to create an app that connects with files across OneDrive, OneDrive for Business, and SharePoint document libraries.
298 questions
{count} votes

2 answers

Sort by: Most helpful
  1. answered 2022-04-07T07:30:55.847+00:00
    Zehui Yao_MSFT 3,346 Reputation points Microsoft Employee

    Hello @Dov Levy (DNA-TECH Computer Solutions) , I tested in postman and please try to add the property content-length in code, hope it helps.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

  2. answered 2022-05-13T12:14:38.533+00:00
    Dov Levy 1 Reputation point

    OP here on a different account.

    Been working on this without success and think I have a breakthrough.

    Summary of issues:

    MS Graph small file upload works but file is corrupted.

    MS Graph resumable large file upload errors out (no code) if I add Content-Length header. If I miss it out, I get response from Graph that header is missing.

    I realised there is one casue for all this. Deluge invokeurl function is inserting a header and footer in to the byte stream. When I remove that after upload, the file opens normally.

    59 bytes at the beginning:

    Content-Disposition: form-data; name="content"; filename="Isabelle blank prescription.docx"
    Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
    Content-Transfer-Encoding: binary

    46 bytes at the end:


    This is why it works fine in Postman but not Zoho Deluge. I'm unsure how to proceed but seems its a fault in Deluge. However I have now seen this is a problem on other platforms.

    Any ideas would be welcome!

    No comments