0
import requests

url = "https://xxxxxx.sharepoint.com/sites/QE/Shared%20Documents/_api/GetFolderByServerRelativeUrl('product-xxxxx-metrics/xxxxx-dashboard-automation')/Files/add(url='test.csv',overwrite=true)"

payload=""
headers = {
  'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxHhZTkdqUhY0TKfWD6PsoOo2SM8Q',
  'Accept': 'application/json;odata=verbose',
  'Content-Type': 'application/json;odata=verbose',
  'Host': 'axtria.sharepoint.com'
}

response = requests.request("POST", url, headers=headers, data= payload)

print(response.text)

Hi, I am using this code snippet to upload files on sharepoint using Python and this I have done using Postman Tool. I am getting no error but the file is also not getting uploaded on the specific location. Would really appreciate if anybody could help.

1 Answer 1

0

What you are missing is the file contents in the payload,

I answered something similar some time ago,

Bad Request for URL- 400

1
  • Hi, Thanks for reverting. In the payload can I add my file which needs to be uploaded from the local system? Commented Dec 1, 2022 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.