We’re Still Here to Help (Even Over the Holidays!) - find out more 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!
1 Reply
- Greg-DB6 years ago
Dropbox Community Moderator
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.
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!