I am using the Request library to test ReST APIs. I am facing a problem while trying to trasform the below cURL to request library Call.
curl https://upload.box.com/api/2.0/files/content \ -H "Authorization: Bearer ACCESS_TOKEN" \ -F filename=@FILE_NAME \ -F parent_id=PARENT_FOLDER_ID
I tried many of the suggestions in this forum. But nothing worked.
The code which I addedd after the comment is:
The code I wrote was:
def upload_a_file(url, folder_id, file_name, access_token):
field_values = "{\'filename\': (filename, open("+file_name+", \'rb\'))}"
payload = "{\'parent_id\':"+folder_id+"}"
request_headers = {'Authorization': 'Bearer '+access_token}
result = requests.post(url, headers=request_headers, data=payload, files=field_values)
response = result.json()
print response