You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
personalizedrefrigerator
7 months agoExplorer | Level 4
GET request to /files/download fails with "The network connection was lost"
Hi, Our app uses Dropbox's HTTP API to upload and download files. Since a few days ago, some of our app's requests are failing with "The network connection was lost". This issue was first reported...
Greg-DB
Dropbox Staff
While we can't offer insight on the client platforms/libraries in particular, this is the right place for help with the Dropbox API itself.
For reference, the Dropbox does use POST for all API calls by default, but "content-download" style endpoints, such as /2/files/download, do additionally support GET. And it's correct that the endpoint does not support POST requests with a non-empty body.
I just tried it out, and confirmed that the API is still allowing both GET and POST for this endpoint in my testing:
curl -v -X POST https://content.dropboxapi.com/2/files/download \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Dropbox-API-Arg: {\"path\":\"/test.txt\"}" \
--header "Content-Type: application/octet-stream"
> POST /2/files/download HTTP/2
> Host: content.dropboxapi.com
> User-Agent: curl/8.4.0
> Accept: */*
> Authorization: Bearer <ACCESS_TOKEN>
> Dropbox-API-Arg: {"path":"/test.txt"}
> Content-Type: application/octet-stream
>
< HTTP/2 200
< content-type: application/octet-stream
< accept-ranges: bytes
< cache-control: no-cache
< dropbox-api-result: {"name": "test.txt", "path_lower": "/test.txt", "path_display": "/test.txt", "id": "id:25N5ksooX-sAAAAAAAQYrQ", "client_modified": "2024-03-11T15:24:40Z", "server_modified": "2024-03-11T15:24:40Z", "rev": "6136423edf446021eccc7", "size": 27, "is_downloadable": true, "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"}
< etag: W/"6136423edf446021eccc7"
< original-content-length: 27
< x-server-response-time: 375
< date: Mon, 06 May 2024 15:09:05 GMT
< server: envoy
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< x-robots-tag: noindex, nofollow, noimageindex
< content-length: 27
< x-dropbox-response-origin: far_remote
< x-dropbox-request-id: d0eb597d801d4203819d86c9b65b42a1
<
* Connection #0 to host content.dropboxapi.com left intact
This is the test file data.
curl -v -X GET https://content.dropboxapi.com/2/files/download \
--header "Authorization: Bearer <ACCESS_TOKEN>" \
--header "Dropbox-API-Arg: {\"path\":\"/test.txt\"}" \
--header "Content-Type: application/octet-stream"
> GET /2/files/download HTTP/2
> Host: content.dropboxapi.com
> User-Agent: curl/8.4.0
> Accept: */*
> Authorization: Bearer <ACCESS_TOKEN>
> Dropbox-API-Arg: {"path":"/test.txt"}
> Content-Type: application/octet-stream
>
< HTTP/2 200
< content-type: application/octet-stream
< accept-ranges: bytes
< cache-control: no-cache
< content-disposition: attachment; filename=unspecified
< content-security-policy: sandbox
< dropbox-api-result: {"name": "test.txt", "path_lower": "/test.txt", "path_display": "/test.txt", "id": "id:25N5ksooX-sAAAAAAAQYrQ", "client_modified": "2024-03-11T15:24:40Z", "server_modified": "2024-03-11T15:24:40Z", "rev": "6136423edf446021eccc7", "size": 27, "is_downloadable": true, "content_hash": "cceac37da5288a6b6716737310c14305c9b16a6e0ff0abce4a306c3de3a59f75"}
< etag: W/"6136423edf446021eccc7"
< original-content-length: 27
< vary: Dropbox-API-Arg, Authorization
< x-content-security-policy: sandbox
< x-content-type-options: nosniff
< x-server-response-time: 340
< x-webkit-csp: sandbox
< date: Mon, 06 May 2024 15:09:29 GMT
< server: envoy
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< x-robots-tag: noindex, nofollow, noimageindex
< content-length: 27
< x-dropbox-response-origin: far_remote
< x-dropbox-request-id: 1eaaff94c0f84f2f91cf96059913ee87
<
* Connection #0 to host content.dropboxapi.com left intact
This is the test file data.
I included the "Content-Type" request header to match your example, but it's not actually required for this. Also, I tried the GET request several times in a row without issue.
So, it does sound like this issue is environment-specific. We'd be happy to look into it further on our side to see if there's something we can do about it from the Dropbox server side, but it's unclear what the issue is exactly so far. Is there a way you could enable some more verbose output (similar to -v for curl above) to gather more information about how exactly the request is failing in the affected environments?
personalizedrefrigerator
7 months agoExplorer | Level 4
Thank you for checking!
> I just tried it out, and confirmed that the API is still allowing both GET and POST for this endpoint in my testing
Locally, I only experience the issue when sending a GET request for the same file two or more times. The first request is successful, but subsequent requests fail, until another file is requested.
> We'd be happy to look into it further on our side to see if there's something we can do about it from the Dropbox server side, but it's unclear what the issue is exactly so far. Is there a way you could enable some more verbose output (similar to -v for curl above) to gather more information about how exactly the request is failing in the affected environments?
I'm not sure how to do this for React Native. As commented above, I was able to reproduce part of the issue in Safari/iOS. I'm attaching screenshots of the "network" tab for a failing and passing GET request in this environment.
Edit: It may be necessary to click on the image above to view it with greater resolution.
Note that I can't reproduce the POST issue in Safari.
- Greg-DB7 months agoDropbox Staff
Thanks! It looks like there's no response received. In cases like that, we'd need to refer to the network client error to see why that failed (e.g., DNS issue, timeout, etc.). It doesn't look like there's much there though, unfortunately. I do see the "TypeError: Load failed". Is there any additional information there if you expand those two dropdown arrows next to that? And is there anything in the "Preview" tab?
- personalizedrefrigerator7 months agoExplorer | Level 4
The "Preview" tab shows an error message:
The dropdown by "TypeError: Load failed" similarly doesn't show additional information.
The right-click menu for the failed request has options that might be helpful:
"Copy HTTP request":GET /2/files/download Authorization: Bearer TOKEN_HERE Content-Type: application/octet-stream Origin: https://js-draw.web.app Referer: https://js-draw.web.app/ Accept: */* Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15 Dropbox-API-Arg: {"path":"/info.json"}
"Copy HTTP response":
NaN null
"Copy as cURL":
curl 'https://content.dropboxapi.com/2/files/download' \ -X 'GET' \ -H 'Authorization: Bearer [[token]]' \ -H 'Content-Type: application/octet-stream' \ -H 'Origin: https://js-draw.web.app' \ -H 'Referer: https://js-draw.web.app/' \ -H 'Accept: */*' \ -H 'Sec-Fetch-Dest: empty' \ -H 'Sec-Fetch-Mode: cors' \ -H 'Sec-Fetch-Site: cross-site' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Safari/605.1.15' \ -H 'Dropbox-API-Arg: {"path":"/info.json"}'
Interestingly, the CURL request is successful when run multiple times in the MacOS terminal app.
I'm now trying to see if I can log network requests made by the iOS simulator (relevant Apple documentation).
- Greg-DB7 months agoDropbox Staff
Thanks for sharing that. Yes, unfortunately it doesn't look like there's anything else useful there.
Just to check, I also tried the curl command a few times but that also worked fine for me.
Logging the failing network requests themselves sounds like a good next step, so let us know if you're able to get anything from that.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,884 PostsLatest Activity: 5 hours 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!