cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Cannot download a file through the api call

Cannot download a file through the api call

tasos91
Explorer | Level 3
Go to solution

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: 

Screenshot 2021-09-23 at 7.18.02 PM.png

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

 

 

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

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.

tasos91
Explorer | Level 3
Go to solution

Ok now this is my request

 

curl --location --request POST 'https://content.dropboxapi.com/2/files/download' \
--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
Screenshot 2021-09-30 at 12.41.07 AM.png
 

Greg-DB
Dropbox Staff
Go to solution

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.

tasos91
Explorer | Level 3
Go to solution

I confirmed with customer! You have right! Thank you very much for your help!

Need more support?