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)"

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)


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


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

I answered something similar some time ago,

Bad Request for URL- 400

  • Hi, Thanks for reverting. In the payload can I add my file which needs to be uploaded from the local system?
    – Kompal
    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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.