Forum Discussion
AmitGogia
Jun 17, 2020Copper Contributor
File Upload in sharepoint Online
Hi All,
I need to upload a simple text file in SharepointOnline. While trying to import the file through Postman, I am getting the error as "Could not get response".
Request help for the case.
- Ashish_KohaleIron Contributor
1) Hope you are not missing any of the steps below:
POST https://{site_url}/_api/web/GetFolderByServerRelativeUrl('/Folder Name')/Files/add(url='a.txt',overwrite=true)
Authorization: "Bearer " + accessToken
Content-Length: {length of request body as integer}
X-RequestDigest: "{form_digest_value}"
To get the access token please follow each steps as per given in below blog(written by me):
2) Also check if your settings for the POSTMAN tool as per below:
setting ->general -> Requesttimeout in ms = 0
- AmitGogiaCopper Contributor
Yes, I am following all the steps. Please look at it.
1. URL: https://abc.sharepoint.com/sites/site_Testing/_api/web/GetFolderByServerRelativeUrl('/sites/site_Testing/Shared Documents/DEF')/Files/add(url='test2.txt',overwrite=true)
2. Below are the Header Parameters that are incorporated:
a. Accept --> application/json;odata=verbose
b. Authorization --> Bearer aasdcsfs
c. x-requestDigest --> iouhdushd8s89
Could you pls tell me the way to calculate content-length(I am not sure regarding this and have put 20).
Also, I had computed x-requestDigest value from http://abc.sharepoint.com/sites/site_Testing/_api/contextinfo
Requesttimeout in ms = 0 (This is done).
Pls let me know the mistake that I had performed so far.
- Ricardo VianaSteel ContributorI am not facing this issue, I would open a MS ticket to have it checked
- AmitGogiaCopper Contributor
Since I am new to sharepoint and might have done something wrong. Hence, I am writing the steps that are performed:
1. API that is build: Site/_api/web/GetFolderByServerRelativeUrl('/Folder name')/Files/add(url='abc.txt',overwrite=true)
2. Authorization, Content length and X-RequestDigest values are passed.
3. File is added in the body header.
Pls let me know in case something is wrong.
- Ricardo VianaSteel ContributorThat is correct, is the folder already created?
Sorry, I have no idea why it is failing