Forum Discussion
On-premise sharepoint API upload pdf error
Hello, I'm trying to upload a PDF on the on-premise sharepoint 2016 through the API with Postman. Here is my setup.
URL: https://test.com/_api/Web/GetFolderByServerRelativeUrl('/somefolder/Shared%20Documents')/Files/Add(url='TestPdf.pdf', overwrite=true)
Authentication: NTLM domain username and password.
Headers:
Body:
Error:
Here's a couple of question
1. Can I use NTLM to upload a file or do I have to setup sharepoint to use bearer token authentication?
2. Why I'm I getting this error? Is it because it can't find the folder? I was able to make a GET API call to that folder to get the detailed information and it worked.
I used to get "Access Denied" but we fixed that issue by giving the user the correct permissions.
I would appreciate any help!
Patrick
I was able to fix this issue by supplying the site name in the url and not in the GetFolderByServerRelativeUrl.
So instead of
https://test.com/_api/Web/GetFolderByServerRelativeUrl('/sitename/Shared%20Documents')/Files/Add(url='TestPdf.pdf', overwrite=true)
use
https://test.com/sitename/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files/Add(url='TestPdf.pdf', overwrite=true)
- ptremblay1515Copper Contributor
I was able to fix this issue by supplying the site name in the url and not in the GetFolderByServerRelativeUrl.
So instead of
https://test.com/_api/Web/GetFolderByServerRelativeUrl('/sitename/Shared%20Documents')/Files/Add(url='TestPdf.pdf', overwrite=true)
use
https://test.com/sitename/_api/Web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files/Add(url='TestPdf.pdf', overwrite=true)