Box Upload API is loading file using Python code , but the file is unreadable.
The file loaded using Postman is readable. The problem happens only with the file loaded using Python code.
The only difference between Postman and Python code is , I am using "verify:false" in order to escape the SSL cert problem.
Please help me on what I am doing wrong. I am attaching the Python code below
import requests
url = "https://upload.box.com/api/2.0/files/content"
payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"attributes\"\r\n\r\n{\"name\":\"TestData.xlsx\", \"parent\": {\"id\": \"***number removed for privacy***\"}}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"C:\\Users\\ABCD\\TestData.xlsx\"\r\nContent-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
headers = {
'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
'Authorization': "Bearer ABCDEFGHIJKLMNOPQRSTUV",
'Cache-Control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers, verify=False)
print(response.text)