We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
prrvchr
16 days agoNew member | Level 2
I can no longer upload files
Hi all, For some time now I have not been able to upload my files via the HTTP API. The file/upload or file/get_temporary_upload_link gives me a 404 error even though it worked perfectly until n...
prrvchr
New member | Level 2
Ok the CURL header that seems to be no longer supported is:
--header "Accept-Encoding: gzip, deflate" \
How is this possible?
Greg-DB
16 days agoDropbox Staff
I just gave this a try myself, but I'm not getting back a 404 error when I use that header. Can you share the full request and response for this issue so we can take a look? If you're using curl, use the -v option to enable verbose mode. Please redact your access token though. Thanks in advance!
- prrvchr16 days agoNew member | Level 2
Hi Greg,
No, it doesn't come from the headers, sorry.
I can get this Curl query to work correctly:
curl -X POST https://content.dropboxapi.com/2/files/upload \ --header "Authorization: Bearer sl.B_2..." \ --header "Dropbox-API-Arg: {\"autorename\":false,\"mode\":\"overwrite\",\"mute\":false,\"path\":\"/Test Dropbox.odt\",\"strict_conflict\":false}" \ --header "User-Agent: python-requests/2.25.1" \ --header "Accept-Encoding: gzip, deflate" \ --header "Accept: */*" \ --header "Connection: keep-alive" \ --header "Content-Type: application/octet-stream" \ --write-out "%{http_code}\n" \ --data-binary "@/home/prrvchr/Test Dropbox.odt"
On the other hand, if I use Python/Requests instead of Curl, it gives me a 404:
import requests url = 'https://content.dropboxapi.com/2/files/upload' headers = {'Content-Type': 'application/octet-stream', 'Dropbox-API-Arg': '{"autorename": false, "mode": "overwrite", "mute": false, "path": "/Test Dropbox.odt", "strict_conflict": false}', 'Authorization': 'Bearer sl.B_2...'} data = open('/home/prrvchr/Test Dropbox.odt', 'rb') response = requests.put(url, headers=headers, data=data) print("Status Code: %s" % response.status_code) response.close() data.close()
I don't see why...
- Greg-DB16 days agoDropbox Staff
Thanks for following up and sharing that. In your Python code, you're using the "PUT" method, via the ".put" call, however the /2/files/upload endpoint expects a "POST". That would be ".post" in the requests library.
- prrvchr16 days agoNew member | Level 2
Thanks Greg for finding my mistakes...
But this code that you just corrected was only created to test the file/get_temporary_upload_link command which has stopped working for some time.
And I just found what was preventing it from working, it is apparently the temporary upload link which no longer supports an Authorization headers which was there by mistake.
Here is an example of code that worked and no longer works, it now returns a status code 500:
import requests url = 'https://api.dropboxapi.com/2/files/get_temporary_upload_link' token = 'Bearer sl.B_...' headers = {'Authorization': token} json = {'commit_info': {'path': '/Test Dropbox.odt', 'mode': 'overwrite'}, 'duration': 3600} response = requests.post(url, headers=headers, json=json) if not response.ok: print("Request on Url: %s give Status Code: %s" % (url, response.status_code)) response.close() else: url = response.json().get('link') response.close() headers = {'Content-Type': 'application/octet-stream', 'Authorization': token} data = open('/home/prrvchr/Test Dropbox.odt', 'rb') response = requests.post(url, headers=headers, data=data) print("Request on Url: %s give Status Code: %s" % (url, response.status_code)) response.close() data.close()
Anyway, all these problems were caused by a mistake in my code and now it is fixed.
Thanks for your help and I think we can close.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!