How to download a file from Sharepoint via REST API (postman) ?

Boaz Benicio 6 Reputation points
2022-08-30T18:16:20.033+00:00

Hi!

I need to download some pdf files from Sharepoint via API but it's not working.

The API response returns a 404 error, stating the file doesn't exist. We tried it by using the GetFileByServerRelativePath method .

endpoint: https://matrixidc.sharepoint.com/sites/dynamicsproducao/_api/Web/GetFileByServerRelativePath(decodedurl=%27/sites/dynamicsproducao/account/SOFA%20DIGITAL%20BRASIL%20LICENCIAMENTO%20E%20CESSAO%20DE%20CONTEUDOS%20LTDA_1450D19E8615EC11B6E7000D3A885B24/11309250A_Proposta_Tecnica%26Comercial_12meses_Matrix_SofaDigital_2021-10-28.pdf%27)/$value

Please verify the attached error:

236170-captura-postman.png

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,583 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,655 questions
{count} vote

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,446 Reputation points Microsoft External Staff
    2022-08-31T07:25:00.49+00:00

    Hi @Boaz Benicio
    Per my test, I can get the pdf file by following url

    https://xxx.sharepoint.com/sites/xiexin/_api/Web/GetFileByServerRelativeUrl('/sites/xiexin/account/SOFA%20DIGITAL%20BRASIL%20LICENCIAMENTO%20E%20CESSAO%20DE%20CONTEUDOS%20LTDA_1450D19E8615EC11B6E7000D3A885B24/11309250A_Proposta_Tecnica%26Comercial_12meses_Matrix_SofaDigital_2021-10-28.pdf')/$value  
    

    236453-image.png
    Please check your path in ( )


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    2 people found this answer helpful.

  2. Prabhu 1 Reputation point
    2022-11-16T08:06:13.8+00:00

    Hi Raytheon Xie,
    I think he wants to know how to download the PDF, and not see it in a text/Unicode format. Not sure if you understood Sumit-5254's question

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.