cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting the shared link using the deprecated GetSharedLinksAsync(path)

Getting the shared link using the deprecated GetSharedLinksAsync(path)

Gonzo345
Helpful | Level 5
Go to solution

Hi there!

 

I'm facing problems retrieving a shared link which is already created. I'm basically trying to "create" the Shared Link every time I upload a file and storing that URL on a DB but I'm stuck on the "shared_link_aready_exists" part.

 

I'm using the .NET API and I tried to use the

DropboxClient.Sharing.CreateSharedLinkWithSettingsAsync(remotePath);

but even if the file is being overwritten, if it already has a Shared Link created, it will give the "shared_link_already_exists" return, stopping there.

 

I've been taking a look at the API and looks like

DropboxClient.Sharing.GetSharedLinksAsync(remotePath)

is my method, but it only works if the link is already created. And poorly, this method is deprecated, so it will surely stop working anytime...

 

I guess there is a way to control that but I'm in a point that I don't move forward. Could anybody help me? Many thanks.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

If a shared link already exists for a file or folder, you can use ListSharedLinksAsync with path as the path to the desired file or folder and directOnly=true to get the existing link.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

If a shared link already exists for a file or folder, you can use ListSharedLinksAsync with path as the path to the desired file or folder and directOnly=true to get the existing link.

Gonzo345
Helpful | Level 5
Go to solution

Hi again, Greg the Dropmaster! Thank you so much, I finally did it this way, so I control if the link is already created and act if so :slight_smile:

 

 var link = await dbx.Sharing.ListSharedLinksAsync(remoteFilePath);
 if(link.Links.Count == 0)
 {
var result = await dbx.Sharing.CreateSharedLinkWithSettingsAsync(remoteFilePath); string url = result.Url; Console.WriteLine("The url for sharing " + remoteFilePath + " is: " + url); } else { string url = link.Links[0].Url; Console.WriteLine("(ALREADY GENERATED) The url for sharing " + remoteFilePath + " is: " + url); }

 

You made my friday, Greg! :sunglasses: 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Gonzo345 Helpful | Level 5
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?