"Download the contents of a DriveItem" does not return the latest changes before the browser tab is closed

Mikael Nyström 1 Reputation point
2022-03-04T11:13:11.643+00:00

Hi :),

We have an integration that enables our users to upload .docx (and similar files) to our platform and then edit them online (SharePoint).

When a user decides to edit a file we upload it temporarily to SharePoint (https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=http).

The online Word editor automatically saves all changes on the fly.

When the user has completed the changes they click a button in our platform to download the latest changes to our platform and update the file on our end.

What I've discovered is that the file does not get updated with the latest changes as long as the SharePoint tab is open.

If I run the request to get the download URL and access it manually I get the old version until I manually close the tab, then I get the latest changes.

Documentation: https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http

I can also get the latest version from the online editor through: File > Save as > Download a Copy. But we need to do this through the API.

Any ideas?

Regards, Mikael

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Diya Ahuja 5 Reputation points
    2023-06-30T18:06:27.8633333+00:00

    The issue you are experiencing is likely due to the fact that the SharePoint tab is still open and the changes have not been saved to the server yet. To ensure that the latest changes are retrieved from the server, you should close the SharePoint tab before making the API call to retrieve the download URL. Additionally, you can use the Files.ReadWrite.All permission to ensure that the latest version of the file is retrieved.

    0 comments No comments