0

I am trying to access a word file from a sharepoint site with the $value which returns the content in unknown format.

GET url is

https://site.sharepoint.com/_api/Web/GetFileByServerRelativePath(decodedurl='/Folder/Document.docx')/$value?binaryStringResponseBody=true

Header is

accept:"application/json; odata=verbose"

Data returned looks like below.

enter image description here

Also I seem to be having difficulty determining the heirarchy of my sites/groups/lists. Is there a way that i can use to know that?

Thank you.

2 Answers 2

0

Please try to use following rest api, per my test it works well.

Remember to change the tenant name,site name, library name and doc name for your own (Team1 Doc127,Document.docx in my test):

https://tenant.sharepoint.com/sites/Team1/_api/web/GetFileByServerRelativeUrl('/sites/Team1/Doc127/Document.docx')/$value?binaryStringResponseBody=true

7
  • Hi, it doesnt make any difference. The returned body is again in strange encoding and i dont konw how to read it.
    – Noman
    Commented Mar 8, 2021 at 15:27
  • Switch to other documents to check if the issue occurs on them.
    – Julie_MSFT
    Commented Mar 9, 2021 at 8:52
  • Yes it is same for all the documents. Word or Excel etc.
    – Noman
    Commented Mar 9, 2021 at 14:15
  • I can download image files in .jpg format for example.
    – Noman
    Commented Mar 9, 2021 at 15:07
  • From the officail article:docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/…, there is no error in your code, I suggest you raise a new support ticket to have a dedicated Technical Professional
    – Julie_MSFT
    Commented Mar 12, 2021 at 7:59
0

So basically I was really stupid. VSCode opens the files in strange encoding. The actual files are ok and they work with microsoft office.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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