You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

bhuwan's avatar
bhuwan
Explorer | Level 3
6 years ago

To get Download able URl

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. 

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox 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.

  • Здравко's avatar
    Здравко
    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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,910 PostsLatest Activity: 3 days ago
333 Following

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 or Facebook.

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!