I have a site on SharePoint Online with some documents in the Shared Documents document library I'd like to download via REST. All the calls I make are returning a bunch of file properties in XML. I can't seem to get the binary file contents. For example:
https://mycompany.sharepoint.com/sites/MySite/_api/web/GetFolderByServerRelativeUrl(
'/sites/MySite/Shared Documents')/Files('MyDocument.docx')
Returns a big XML document including:
<m:properties>
<d:CheckInComment/>
<d:CheckOutType m:type="Edm.Int32">2</d:CheckOutType>
<d:ContentTag>{2b9067cd-cb9b-4643-a9d6-19ef489b33e4},1,2</d:ContentTag>
<d:CustomizedPageStatus m:type="Edm.Int32">0</d:CustomizedPageStatus>
<d:ETag>"{2b9067cd-cb9b-4643-a9d6-19ef489b33e4},1"</d:ETag>
<d:Exists m:type="Edm.Boolean">true</d:Exists>
<d:IrmEnabled m:type="Edm.Boolean">false</d:IrmEnabled>
<d:Length m:type="Edm.Int64">19900</d:Length>
<d:Level m:type="Edm.Byte">1</d:Level>
<d:LinkingUri>https://mycompany.sharepoint.com/sites/MySite/Shared%20Documents/MyDocument.docx?d=w2b9068bccb9b4643a9d619ef489b33e3</d:LinkingUri>
<d:LinkingUrl>https://mycompany.sharepoint.com/sites/MySite/Shared Documents/MyDocument.docx?d=w2b9068bccb9b4643a9d619ef489b33e3</d:LinkingUrl>
<d:MajorVersion m:type="Edm.Int32">1</d:MajorVersion>
<d:MinorVersion m:type="Edm.Int32">0</d:MinorVersion>
<d:Name>MyDocument.docx</d:Name>
<d:ServerRelativeUrl>/sites/MySite/Shared Documents/MyDocument.docx</d:ServerRelativeUrl>
<d:TimeCreated m:type="Edm.DateTime">2020-05-07T20:38:53Z</d:TimeCreated>
<d:TimeLastModified m:type="Edm.DateTime">2020-05-07T20:38:53Z</d:TimeLastModified>
<d:Title/>
<d:UIVersion m:type="Edm.Int32">512</d:UIVersion>
<d:UIVersionLabel>1.0</d:UIVersionLabel>
<d:UniqueId m:type="Edm.Guid">2b9067cd-cb9b-4643-a9d6-19ef489b33e4</d:UniqueId>
</m:properties>
From what I've seen elsewhere, adding /$value
to the end of the URL should return the file contents, but it just returns the same XML.