Take Your Search Game to the Next Level with Dropbox Dash 🚀✨ Curious how it works? Ask us here!
Forum Discussion
tasos91
4 years agoExplorer | Level 3
Cannot download a file through the api call
I cannot download files with the api-call bellow
curl --location --request POST 'https://content.dropboxapi.com/2/files/download' \ --header 'Authorization: Bearer <REDACTED>' \ --header 'Content-Type: application/octet-stream; charset=utf-8' \ --header 'Dropbox-API-Select-User: dbmid:AADVooZVTYhULkIUtBUVxhZRu0VePEYdr8A' \ --header 'Dropbox-API-Arg: {"path": "/TasosFolder/a.csv"}' .
The path is correct but I get
{ "error_summary": "path/not_found/.", "error": { ".tag": "path", "path": { ".tag": "not_found" } } }
The file as you can see in the image bellow is in the correct path:
This is important since I have implemented code for getting all the files from a directory and I have stuck here and this is for a customer who want to have access in getting data from Dropbox through my company's product.
Can anyone help?
Thank you in advance,
Tasos
It looks like the file you're referring to is located in the "team space". API calls default to the "member folder", not the team space though, so to access anything in the team space you will need to also specify the "Dropbox-API-Path-Root" header. Please refer to the Team Files Guide for information on using that:
https://developers.dropbox.com/dbx-team-files-guide
By the way, note that access tokens enable access to Dropbox accounts/teams, so for the sake of security, you should never share access tokens like this. I redacted it from your post, but since this access token has been shared here, you should disable this access token. You can do so by revoking access to the app entirely, if the access token is for your team and you are a team admin, here:
https://www.dropbox.com/team/admin/settings/team_apps
Or, you can disable just this access token using the API:
https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
Note that doing so will cause any further API calls made using this access token to fail. This cannot be undone, and you would need to get a new access token to replace this one.
4 Replies
Sort By
- Greg-DB
Dropbox Staff
It looks like the file you're referring to is located in the "team space". API calls default to the "member folder", not the team space though, so to access anything in the team space you will need to also specify the "Dropbox-API-Path-Root" header. Please refer to the Team Files Guide for information on using that:
https://developers.dropbox.com/dbx-team-files-guide
By the way, note that access tokens enable access to Dropbox accounts/teams, so for the sake of security, you should never share access tokens like this. I redacted it from your post, but since this access token has been shared here, you should disable this access token. You can do so by revoking access to the app entirely, if the access token is for your team and you are a team admin, here:
https://www.dropbox.com/team/admin/settings/team_apps
Or, you can disable just this access token using the API:
https://www.dropbox.com/developers/documentation/http/documentation#auth-token-revoke
Note that doing so will cause any further API calls made using this access token to fail. This cannot be undone, and you would need to get a new access token to replace this one.- tasos91Explorer | Level 3
Ok now this is my request
--header 'Authorization: Bearer <token>' \--header 'Content-Type: application/octet-stream; charset=utf-8' \--header 'Dropbox-API-Select-User: dbmid:AABpiqc0an7cRcBJJuGjlVKAqP4NcHekymI' \--header 'Dropbox-API-Path-Root: {".tag": "root", "root":"2005609681"}' \--header 'Dropbox-API-Arg: {"path": "/TasosFolder/a.csv"}'And the response I get is three curls with status 200..I don't think that this is what I expected right?curl -X POST https://api.dropboxapi.com/2/auth/token/from_oauth1 \
--header "Authorization: Basic ==" \
--header "Content-Type: application/json" \
--data "{\"oauth1_token\": \"\",\"oauth1_token_secret\": \"\"}"
curl -X POST https://api.dropboxapi.com/2/check/user \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data "{\"query\": \"foo\"}"curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--header "Dropbox-API-Select-User: tasos.sotiriou91@gmail.com" \
--data "{\"path\": \"/Homework/math\",\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}"
curl -X POST https://api.dropboxapi.com/2/file_requests/list_v2 \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data "{\"limit\": 1000}"
curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--header 'Dropbox-API-Select-User: dbmid:AADVooZVTYhULkIUtBUVxhZRu0VePEYdr8A' \
--data "{\"path\": \"/Content/Aisera/\",\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}"
curl --location --request POST 'https://api.dropboxapi.com/2/files/list_folder' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Dropbox-API-Select-User: dbmid:AADVooZVTYhULkIUtBUVxhZRu0VePEYdr8A' \
--data-raw '{
"path": "/Nested_Folder/",
"shared_link": {
"url": "https://www.dropbox.com/scl/fo/c226494o7l56vislcx3e6/AACvV0kUpMlUupr-4zcwnZRma?dl=0"
}
}'
curl -X POST https://api.dropboxapi.com/2/files/get_metadata \
--header "Authorization: Bearer <token>" \
--header 'Dropbox-API-Select-User: dbmid:AADVooZVTYhULkIUtBUVxhZRu0VePEYdr8A' \
--header "Content-Type: application/json" \
--data "{\"path\": \"/\",\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}"
{"path":"\/Aisera","shared_link":{"url":"https:\/\/www.dropbox.com\/scl\/fo\/c226494o7l56vislcx3e6\/AACvV0kUpMlUupr-4zcwnZRma?dl=0"}}Also, You can see the image bellow of what I get- Greg-DB
Dropbox Staff
A 200 status code indicates that the call succeeded, which for /2/files/download means that the requested file data is returned in the response body. So, it looks like your "a.csv" file actually contains that sample curl code, and your client is showing it as text there in that "Body" section.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,990 PostsLatest Activity: 2 hours ago
If 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!