According to the following link:

Working with folders and files with REST

I can add a file using

url: http://site url/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files/add(url='a.txt',overwrite=true)
method: POST
body: "Contents of file"
    Authorization: "Bearer " + accessToken
    X-RequestDigest: form digest value
    content-length:length of post body

I am testing this with Postman. In my post request I set the body to form-data and add a file parameter with a text file called "a.txt". The text file contains the text:


When I execute my request in Postman my text file is present in SharePoint. When I open the file on SharePoint the contents of the file is:

Content-Disposition: form-data; name="file"; filename="a.txt"
Content-Type: text/plain


I want to do this action by only using plain HTTP calls. Is this behaviour correct? It looks like a file is created and the content is filled with my formdata.

1 Answer 1


Setting the body to binary in Postman fixed my problem. Key is setting the correct content-length otherwise the file will get corrupted.

Get the content length of thee file with PowerShell

$file = "c:\temp\file.docx"
(Get-Item $file).Length

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.