0

I am new to Sharepoint and REST APIs and am currently having an issue uploading a file using REST API. I am getting error System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied."}}}|403 when uploading a file.

I am using OAuth and have the tenant ID, client id, and client secret. I have no issue getting the client credentials. But when calling: https://[tenant].sharepoint.com/sites/[site]/_api/web/GetFolderByServerRelativeUrl('[folder dir]')/Files/add(url='test_file.txt',overwrite=true) then I get the 403 error as response.

Here are my HTTP Headers:

"Authorization": "Bearer" + access token
"Accept": "application/json;odata=verbose"
"Content-Length": *length of file*

Is this an add-in permission issue or am I missing a header? Thanks in advance for your help.

1
  • How are you submitting the request to SharePoint? For example, are you using jQuery or the Fetch API in JavaScript or are you using the SPHttpClient in SharePoint Framework? Dec 12, 2022 at 11:20

1 Answer 1

0

You need a Form Digest - an X-RequestDigest header - to POST to SharePoint APIs.

How to get 'form digest value' to use in REST call?

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.