cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

To get Download able URl

To get Download able URl

bhuwan
Explorer | Level 3

I have try to use the way I was told in my previous ticket.

try{
$client->request('POST', config('providers.providers.dropbox.create_shared_link'),
[
'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'];
$url = str_replace('dl=0', 'dl=1', $url);
return $url;
}


 However, sometime endpoint is not responding anything either in call or exception. Need to solve this issue. 

2 Replies 2

Greg-DB
Dropbox Staff

Looking at your code, a few things come to mind:

  • You're always calling `json_decode` in the exception handler, assuming the error response is always JSON, but this isn't necessarily true. (It can be plain text, for instance.) You should first check the response's Content-Type header value to determine the type of the response. 
  • You're only catching `ClientException`, however there might be other kinds of exceptions. (I can't provide support for the client you're using though, so I can't say for sure.)
  • You may be running in to an issue with your network connection. Is there any firewall, proxy, anit-virus, etc. on your network connection that may be interfering?

In any case, I recommend stepping through with a debugger to see exactly where code execution is going. If you're getting any unexpected error or output from the Dropbox API itself, share it here so we can look into it.

Здравко
Legendary | Level 20

Hi @bhuwan,

In your code shared link existence is expected! Right? What about if such link don't exist yet and is just created?! :thinking: :wink:

Hope this gives some direction.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?