I'm trying to post a file from an external application to SharePoint using the REST API. Trying this via Postman first to get the structure of the Body. It works well when I'm attaching the PDF file in the 'binary' mode of the Body. The file is successfully posted to the SharePoint Directory and pdf is accessible.

When I convert the PDF to Base64 format and add it in 'Raw' mode of the Body and post the file to SharePoint, the PDF cannot be opened and is corrupted. enter image description here

Please help me with the correct format to upload the content in the 'Raw' mode ? Need to post the REST API with the Base64 format of PDF because external system will convert the PDF to Base64 image.

1 Answer 1


Can the external application use jQuery? Here is one example of uploading files to SharePoint via REST API through jQuery, PLEASE NOTE, this uses FileReader API (HTML 5).

Here are the steps to be done by the example:

  1. Convert the local file to an array buffer by using the FileReader API, which requires HTML5 support. The jQuery(document).ready function checks for FileReader API support in the browser.

  2. Add the file to the Shared Documents folder by using the Add method on the folder's file collection. The array buffer is passed in the body of the POST request.

These examples use the getfolderbyserverrelativeurl endpoint to reach the file collection, but you can also use a list endpoint (example: https://{site_url}/_api/web/lists/getbytitle('{list_title}')/rootfolder/files/add).

  1. Get the list item that corresponds to the uploaded file by using the ListItemAllFields property of the uploaded file.

  2. Change the display name and title of the list item by using a MERGE request.

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.