Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
mnoah66
8 years agoExplorer | Level 4
Share a file, then return the URL ONLY
I am using Python to share an image. Then, I want to be able to only print to the console the short url. How do I accomplish this?
With this:
print(client.share(path))
I get:
...
- 8 years ago
The share method you're using returns a dict, so you can access the fields like:
print(client.share(path)['url'])
That uses API v1 though, which is deprecated. You should switch to using API v2. Using API v2, creating a shared linked is accomplished using the sharing_create_shared_link_with_settings method, which returns a SharedLinkMetadata object. Using it would look like this (also including the construction of the client itself):
dbx = dropbox.Dropbox(ACCESS_TOKEN)
print(dbx.sharing_create_shared_link_with_settings(path).url)
Greg-DB
Dropbox Community Moderator
8 years agoThe share method you're using returns a dict, so you can access the fields like:
print(client.share(path)['url'])
That uses API v1 though, which is deprecated. You should switch to using API v2. Using API v2, creating a shared linked is accomplished using the sharing_create_shared_link_with_settings method, which returns a SharedLinkMetadata object. Using it would look like this (also including the construction of the client itself):
dbx = dropbox.Dropbox(ACCESS_TOKEN)
print(dbx.sharing_create_shared_link_with_settings(path).url)
- mnoah668 years agoExplorer | Level 4
That worked! Thank you
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
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!