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?


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:


  • 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. – Ayushi Goel Dec 20 '19 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': '' } – Burre Ifort Sep 23 '20 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.