Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
Paul M.131
9 years agoExplorer | Level 4
Trouble with link and setting expiry date
I am creating a .NET app and all is working well so far with v2.1. I can share a link, but if try to add an expiry date for the link it fails at the "CreateSharedLinkWithSettingsAsync" method, with a "settings_error/not_authorized/.." error!
I have read the .NET documentation, and searched the forums, but cannot get this working.
This is my code:
Dropbox.Api.Sharing.CreateSharedLinkWithSettingsArg shArgs = null;
//set the expiry date
Dropbox.Api.Sharing.SharedLinkSettings shSett = new Dropbox.Api.Sharing.SharedLinkSettings(null, null, DateTime.Today.AddDays(1));
var file = (FileMetadata)listView1.SelectedItems[0].Tag;
//The code work if I replace the 'shSett' variable with 'null' in this line of code
shArgs = new Dropbox.Api.Sharing.CreateSharedLinkWithSettingsArg(file.PathDisplay, shSett);
//this is the line where the error occurs
var result = await client.Sharing.CreateSharedLinkWithSettingsAsync(shArgs);
Any help appreciated. Hopefully I have provided enough information.
Paul
4 Replies
Replies have been turned off for this discussion
- Greg-DB9 years ago
Dropbox Community Moderator
Hi Paul, you can find more information on this error in the documentation here:
In this case, it looks like the issue is that you're trying to set an expiration on a link using an account that doesn't have access to that feature.
- Paul M.1319 years agoExplorer | Level 4
Hi Gregory,
Many thanks for your response and advice, and you were indeed correct, so I have now upgraded from the free account to Pro.
However, I now have a new problem, which is "Error in call to API function \"sharing/create_shared_link_with_settings\": request body: settings.expires: time data '2016-04-24T00:00:00' does not match format '%Y-%m-%dT%H:%M:%SZ'"}.
As far as I can see, the problem is arising in the Dropbox.Api.SharedLinkSettingsEncoder class, which has a DateTime value passed in, and where the "expires" value is:
{{"path":"/Chrysanthemum.jpg","settings":{"expires":"2016-04-24T00:00:00"}
Using the API Explorer and reading the error message, it appears that there should be a "Z" appended to the time in the settings, but I'm not sure how to achieve this.
Not sure if it has anything to do with being a UK time format.
Paul
- Greg-DB9 years ago
Dropbox Community Moderator
I believe that should be fixed in version 3.0.6. Please update to that and let me know if it doesn't help.
- Paul M.1319 years agoExplorer | Level 4
Fantastic Gregory. I have updated the Dropbox.Api and it now works perfectly.
Many thanks for your quick response and helpful advice.
Paul
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!