question

StephanMethner-8164 avatar image
0 Votes"
StephanMethner-8164 asked saldana-msft edited

Graph API - Restoring a DriveItemVersion as a new file in OneDrive

Hi there,

I'm using the Graph API to access Excel files in my OneDrive (works great!).

Actually I'm trying to access older versions of my Excel files. I can get a list with "/versions". I also can get some detail information about a specific version with "/versions/x.0.

Now I would like to restore one of these DriveItemVersions as a new OneDrive file (in another folder) - not overwriting my actual version.


Or if this is not possible - download that version file.

I'm developing a browser only React app (not node.js) and even have problems with getting the content of such a file:

 let res = await client.api("/me/drive/items/01Y5BOJUKNFSJVM6VB6J.../versions/2.0/content").get();



@Danstan

I appreciate any help. Thanks in advance

Best
Stephan

microsoft-graph-sdkmicrosoft-graph-filesmicrosoft-graph-sites-lists
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AmosWu-MSFT avatar image
0 Votes"
AmosWu-MSFT answered

Hi @StephanMethner-8164,
The restore operation will only restore the file to the location of the current file, and cannot restore the file to other folders or libraries. To download files from OneDrive in a JavaScript app you cannot use the /content API, since this response with a 302 redirect. A 302 redirect is explicitly prohibited when a CORS preflight is required, such as when providing the Authorization header.
You could take a look at this document:Using the OneDrive API in JavaScript apps (CORS support)


If the response 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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.