One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
chunchk
8 years agoExplorer | Level 4
How do I make apiError as a string
Hello, I am new in here
I try to develop a script that can auto email a Dropbox link to someone
I am using .sharing_create_shared_link_with_settings to determine does the file had been shared or not
However, now I encounter a new python exception which is "not_found",
my situation is, now I have 2 python exceptions, "not_found" and "shared_link_already_exists"
my question is, how do I let python know that the exception is "not_found" or "shared_link_already_exists" , so I can code some actions depends on the different exception
- Greg-DB
Dropbox Staff
Here's an example of how you can tell apart different errors:
import dropbox from dropbox.exceptions import ApiError dbx = dropbox.Dropbox("<ACCESS_TOKEN>") try: print(dbx.sharing_create_shared_link_with_settings("/test222.txt")) except ApiError as err: if err.error.is_shared_link_already_exists(): print("Link already exists.") if err.error.is_path() and err.error.get_path().is_not_found(): print("File not found.") elif err.error.is_settings_error(): print(err.error.get_settings_error()) else: print(err)
- chunchkExplorer | Level 4
Oh~I see~!
Thank you for your help
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 15 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!