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.

Kalpesh Vaghela
  • 2,215
  • 1
  • 12
  • 25
Kompal
  • 21
  • 3

1 Answers1

0

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

I answered something similar some time ago,

Bad Request for URL- 400

Murtuza Husain
  • 139
  • 1
  • 13
  • Hi, Thanks for reverting. In the payload can I add my file which needs to be uploaded from the local system? – Kompal Dec 01 '22 at 06:15