One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
omahacircusarts
6 years agoNew member | Level 2
Python - what to type to get the shared link of a file?
I need a little bit of python help. I've learned how to create a shared link, but if a shared link is already created on that file, it errors out.
shared_link_metadata = dbx.sharing_create_shared_link_with_settings("/temp/hehe.txt")
print (shared_link_metadata.url)
How do I check if the link already exists and how do I check the link if one is already created? Thanks!
- Greg-DB
Dropbox Staff
The sharing_create_shared_link_with_settings method will throw an exception if a shared link is already created for the specified path. You can catch that, and use CreateSharedLinkWithSettingsError.is_shared_link_already_exists to determine if that's the reason the call failed. If so, you can use CreateSharedLinkWithSettingsError.get_shared_link_already_exists to get the error value, which may include the metadata of the existing shared link.
Alternatively, you can first call sharing_list_shared_links with the 'path' and 'direct_only=True' to check if a link already exists for the particular path, and retrieve it if so.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 9 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!