0

I want to get the metadata and file of many documents via REST API. The documents are stored in a document library. Requesting metadata and file can not be done transactionally via one REST request. So I request the metadata for document at a timestamp A, which returns me a specific version id (for example 512). Then some operations are applied locally on metadata. After that, I want to download the file for the given document version id in one single request. I don't know, if the document has been changed at the server since timestamp A and the timestamp, when I want to download the file. According to my observations, I can not download the file via (1)...

<host,site>/GetFileByServerRelativeUrl('<file-relative-url>')/$value

..., because this would only returns the file of the current document version at the server, which could be changed since timestamp A.

Via (2)...

<host,site>/GetFileByServerRelativeUrl('<file-relative-url>')/versions(<version id>)/$value

...I get the file of a specific document version. But according to my observation, this URL is only for requesting files of historical document version ids. If I try to get the file of current document version via Request (2) with <version id>=512 and 512 is still the current document version at the server, null is returned.

Does somebody know, if there is a URL, which I can use to download the file for any document version (historical and current) like

<host,site>/GetFileByServerRelativeUrl('<file-relative-url>')/versionsIncludingCurrent(<version id>)/$value

Sure, I can check, if the document version 512 is still the current version, and then decide, if I download it via Request (1) or (2). But that means, that I have to call the server again to check this - for one document, it's no problem. If there a thousands or millions of documents, the performance could decreases signifcantly. So I want to avoid such additional calls.

Thank you in advance

0 Answers0