Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I am trying to download a file using rest service using V2 API.
curl -X POST https://api.dropboxapi.com/2/file_requests/get \ --header "Authorization: Bearer <Access Token>" \ --header "Content-Type: application/json" \ --data "{\"id\": \"oaCAVmEyrqYnkZX9955Y\"}"
Where I can get the file id?
Thanks in advance.
You can get the ID for a file or folder from the Metadata object for the file or folder, e.g., as returned by /2/files/get_metadata or /2/files/list_folder.
If you want to download a file though, you should use /2/files/download (not /2/file_requests/get). For /2/files/download you can supply either the path or ID of the file you want to download. (The /2/file_requests/get endpoint is for getting the information about a file request, not a file, by specifying the ID for the file request.)
Thanks Greg.
Greg,
The documentation recommends using the File Id, because it is more reliable than the path which changes when the file is moved:
2. File id (e.g. id:odTlUvbpIEFAAAAAAAAGOQ)
- Unique file reference that persists if files are moved or renamed
- Useful for apps referencing files that are moved around
- Best choice for reliable, accurate reference to a specific file
But you indicate the only way to get the id is to use the path name. So programmatically, (I'm writing API calls to manage files/folders from our apps in Salesforce) I need to grab file ids, maybe as each file/folder is created, and store them locally (in Salesforce) so that in the future, I can always find the file? Not sure how I'd index that store of ids. I could use file name, if I could guarantee every file name is unique across our enterprise, which I can't.
Seems like I'm stuck with path names, and trying to train users to not mess with the folder structure. Am I missing something?
@bob-locascio For reference, while you can get the file ID for a file using its path, that's not the only way to do so. You can get the file ID for a file from any FileMetadata object for the file; FileMetadata objects are used in a number of places on the Dropbox API. For example, you can use /2/files/list_folder[/continue] to list the contents of a folder, such as by supplying the folder's path or ID, or empty string "" for root, and get the file IDs for files in that folder from the returned FileMetadata objects. (If you're interested, you can see all of the places where FileMetadata is used in the API specification.)
Anyway, I don't know exactly what constraints and requirements you have in your own environment, but in Dropbox itself, note that in an account multiple files can have the same file name (that is, different files in different folders can have the same name), but multiple files can't have the same file path (that is, different files in the same folder can't have the same name). Dropbox file IDs are unique across all of Dropbox.
Exactly how you store any such metadata on your side is up to you, depending on what you need your app to do and how, so I can't really offer specific guidance on how you should structure that.
Hi there!
If you need more help you can view your support options (expected response time for a 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!