cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

create_shared_link_with_settings responding conflict 409

Highlighted

create_shared_link_with_settings responding conflict 409

Explorer | Level 3

Hi, 

create_shared_link_with_settings responding 409 conflict error but it is passing data in exception. So I try to this

$client = new Client();
$parameters = [
"path" => "id:".$imageId,
];
$url = '';
try{
$response = $client->request('POST', 'https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings',
[
'headers'=>
[
'Authorization'=>'Bearer '.$acc_token,
'Content-Type' => 'application/json',
],
'body'=>json_encode($parameters)
]);
}catch(ClientException $exception){
$url = json_decode($exception->getResponse()->getBody(), true)['error']['shared_link_already_exists']['metadata']['url'];
}
return $url;

When I catch exception I am able to get the URL as needed. Please advise me how I can avoid conflict error.

1 Accepted Solution

Accepted Solutions
Highlighted

Re: create_shared_link_with_settings responding conflict 409

Dropboxer

The /2/sharing/create_shared_link_with_settings endpoint will always return a 'shared_link_already_exists' error if a shared link for the requested item already exists. Catching and handling the exception is the proper way to accommodate that. (Note that there are other possible error types as well. You can find them listed in the documentation.)

If you want to avoid that though, you can first call /2/sharing/list_shared_links to check for an existing link. (You'll probably want to use 'direct_only:true' in this case.)

View solution in original post

1 Reply 1
Highlighted

Re: create_shared_link_with_settings responding conflict 409

Dropboxer

The /2/sharing/create_shared_link_with_settings endpoint will always return a 'shared_link_already_exists' error if a shared link for the requested item already exists. Catching and handling the exception is the proper way to accommodate that. (Note that there are other possible error types as well. You can find them listed in the documentation.)

If you want to avoid that though, you can first call /2/sharing/list_shared_links to check for an existing link. (You'll probably want to use 'direct_only:true' in this case.)

View solution in original post

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?