1
votes

I am testing a file upload to SharePoint online with Postman. In my post request I set the body to form-data and add a file param with a text file called a.txt. The text file contains the text

one
two
three

When I execute the request my file is uploaded but when I open the file the contents is

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

one
two
three
----------------------------235004

I have tried setting the Content-Type header to

application/x-www-form-urlencoded or multipart/form-data

But no luck

2

2 Answers

7
votes

Please follow the below steps-

1. Go to the body of the API
2. pass the parameter or key
3. When you pass the key you have a option of value of Text/File like below
4.Choose the file from
5. Click on send.
6. Get your response.

Hope this helps buddy.

enter image description here

0
votes

In my case setting the body to type binary solved my problem with testing with Postman