0

I am using below endpoint to get the content of file in sharepoint:

https://<site>/_api/web/GetFolderByServerRelativeUrl('folder name')/Files('file name')/$value?binaryStringResponseBody=true

But this is returning a response in octet stream and the content type of response is application/octet-stream. Is there a way to get the content in human readable format directly? If not , is there a way to convert it into other format in java?

1
  • As far as I know, neither the REST API or the Client Object Model supports the functionality you're looking for. Feb 16 at 12:36

1 Answer 1

1

We need to use the below API:

GET https://mysite.sharepoint.com/<site_name>/_api/web/lists(guid'<list-id>')/items(<item-id>)/File

api of sharepoint using list id and item id obtained from /getchanges api. Then use the ServerRelativeUrl field of response to obtain file contents by calling :-

GET http://mysite.sharepoint.com/<site_name>/_api/web/getfilebyserverrelativeurl('<url>)/$value?binaryStringResponseBody=true

Reference URL:

How to point to/get the file contents or file from SharePoint changes api call

how to get file content from sharepoint list using restapi in java

Similar question discussed here:

https://stackoverflow.com/questions/48422868/how-to-get-file-content-from-sharepoint-list-using-restapi-in-java

2
  • Thanks for answering this. But as i mentioned in the question getFileByServerRelativeUrl api is returning the response in octet-stream. Iam looking for an api to get response as plain text. Dec 20, 2019 at 6:36
  • You have to change the header type that you are accepting. Put it to accept json. Like this: headers: { 'Accept': 'application/json;odata=nometadata', 'odata-version': '' } Sep 23, 2020 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.