Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
bneese
10 months agoNew member | Level 1
Save URL Endpoint for Public Folders via API
When I use the files/save_url API endpoint and enter the URL of a public folder, I get an invalid_url error. I am assuming this is because this endpoint only works on files, not folders, is that correct? Or is the issue with public links, since this folder wasn't shared with me via Dropbox and doesn't exist in my Dropbox account?
Is there an option to save a folder and its subfolders/files via the API? My intent is for this to have the same effect as a user clicking the "Copy to Dropbox" button that appears when viewing a public Dropbox folder.
Thanks in advance!
9 Replies
- DB-Des10 months ago
Dropbox Community Moderator
Hi bneese,
You are correct, the endpoint /files/save_url is meant to save data from a specified URL into a file. That said, I'll pass this along as a feature request. I can't promise if or when that might be implemented though.
While it is not possible to save/copy folders directly to Dropbox via the API, especially from a URL, there is the option of creating folders via /files/create_folder_v2 or /files/create_folder_batch.
An option to simulate the "Copy to Dropbox" action, could be to retrieve the folder names from one Dropbox account, by calling /files/list_folder/[continue], and then have your app/integration create folders with the same name and hierarchy via /files/create_folder_v2 or /files/create_folder_batch on another Dropbox account.
- bneese10 months agoNew member | Level 1
Hi DB-Des,
Thanks for the quick reply! That would be a great feature for me, thank you for passing it along as a request.
I have thought about simulating the "Copy to Dropbox" action similar to how you mentioned, but can I call the /files/list_folder action on a public URL? In my use case, the owner of the Dropbox folder is not willing to "share" the folder with anyone, they will only expose the contents via a public URL.
- DB-Des10 months ago
Dropbox Community Moderator
Hi bneese,
To allow an API app to act on a user's behalf, the user would need to grant consent through the OAuth authorization flow. This ensures the app has the necessary permissions to perform actions on the user's behalf.
Regarding your question about calling the /files/list_folder from a public URL, could you provide more details on your specific use case? As previously mentioned, authorization would need to be granted by users in order to make requests to the Dropbox API.
- bneese10 months agoNew member | Level 1
Hi DB-Des,
Thanks again for your help. For now, I have am using an access token to test the logic and then I'll work on the OAuth flow.
Here's an example of a public URL I would be working with: 1115 Shady Lane 1-21-25 - Dropbox
This example contains a single folder with a few files inside, but the main use case would be hundreds of subfolders with more subfolders and files.
Since there is no save_url action for folders, I would iterate over the folder & files and use create_folder_batch and copy_batch_v2 to recreate the folder structure and copy the files, as you suggested.
My issue is that I can't find a way to use /list_folder on a URL, since the example folder hasn't been shared with me via Dropbox and isn't in my account, so I can't enter its name in the "path" parameter.
Sorry if this isn't clear, let me know and I can try to explain it another way.
- DB-Des10 months ago
Dropbox Community Moderator
Hi bneese,
Thank you for providing additional context. In the case of the /files/list_folder[continue] endpoint, the path parameter only accepts paths relative to the authorized user's Dropbox. It is not possible to pass a URL as the path for that endpoint either.
- bneese10 months agoNew member | Level 1
Hi DB-Des,
Understood, thank you. It is a bummer that there is a very limited number of endpoints that can accept URLs. Please let me know if that changes in the future.
- DB-Des10 months ago
Dropbox Community Moderator
My apologies, after reviewing the developer documentation, I realized there is actually a way to pass a share link URL to the /files/list_folder endpoint.
You can pass that link to the shared_link parameter. Note that in this case, the path will be relative to root of the shared link.
- bneese10 months agoNew member | Level 1
Hi DB-Des,
That's a good point about the shared_link parameter. Because the folder wasn't specifically shared with me, but rather is a publicly accessible link, will this work? I'm getting an error using the Python SDK: "expected type dropbox.files.ShareLink, got string".
If I try using the /sharing/list_folders endpoint, no shared links are returned since there are no folders specifically shared with the current user (again, trying to use this on public URLs).
Am I just doing something wrong in how I'm formatting my shared_link parameter?
dbx = dropbox.Dropbox(access_token) save_url = 'https://www.dropbox.com/scl/fo/qva8f9u5ivu7r6uq4c0w5/APiGek2ClDY99vfvErrHPm8/_2025/1115%20Shady%20Lane%20%201-21-25?dl=0&rlkey=gx9b5grnz5t02o9aqxndjeqdn' dbx.files_list_folder(shared_link=save_url, path='') - DB-Des10 months ago
Dropbox Community Moderator
The error you’re encountering is due to parameter 'shared_link' expecting a value of type 'SharedLink' rather than a string. The reason for this is that shared URLs could be password-protected, and by providing an object of type 'SharedLink', you ensure that both the string and any associated password can be included properly.
In your case, you can just modify your 'save_url' parameter as such:
save_url = dropbox.files.SharedLink(url="<SHARED_LINK_URL>")
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!