Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent 403-Forbidden when uploading files (using Files/Add) #80

Open
cesarvegamx opened this issue Feb 27, 2024 · 2 comments
Open

Recent 403-Forbidden when uploading files (using Files/Add) #80

cesarvegamx opened this issue Feb 27, 2024 · 2 comments

Comments

@cesarvegamx
Copy link

cesarvegamx commented Feb 27, 2024

I've been using this library for a couple of years in my organization.
We use it to get and put files in sharepoint for further processing by an ETL.

Since a last week all the Files/add operation stopped to work in our three environments: dev, staging, prod.
Reading files from sharepoint still works everywhere.

full_url = "https://mycompany.sharepoint.com/sites/"+p_site+"/_api/web/GetFolderByServerRelativeUrl('/sites/"+p_site+"/Shared Documents/"+p_remote_folder+"/')/Files/add(url='"+p_file_name+"',overwrite=true)";
We're getting a 403-forbidden response.

I must clarify that the account used for our connection has full permissions on the sharepoint (remember it was working, its not a new development).

I tried the same operation using postman: same url, same account, and there, I could succesfully add the file to sharepoint.

It seems like a recent change in sharepoint broke the Files/add method.

@JobrJobrJobr
Copy link

I think I've been having a similar issue. We have two scripts that use Sharepy to update a sharepoint table and upload data to our sharepoint site. We had never had an issue with them, until a few weeks ago, around the same time this issue was created. We don't run them very often, about once every three months, so they may have stopped working before this point.

@JobrJobrJobr
Copy link

I was able to sort out this issue. To fix, I opened a connection to our sharepoint site. Then sent an empty post to:
https://<company_name>.sharepoint.com/sites/<site_name>/_api/contextinfo
From that response, I extracted the Form Digest Value and added it to the "X-RequestDigest" header of all future posts in the automation script.
The post function in sharepy takes similar steps to acquire a digest value, but it instead assigns it to the "Authorization" header.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants