cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 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

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

Re: To get Download able URl

Dropboxer

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.

Re: To get Download able URl

Super Collaborator | 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?!

Hope this gives some direction.

Polls
Are you starting new work habits this year?

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?