We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I testing the shared link function. I generated one, but when I requests the same function I got this error:
{"error_summary": "shared_link_already_exists/.", "error": {".tag": "shared_link_already_exists"}}
How to check if shared link exists and than use that or create a link if it don't exists?
The text was updated successfully, but these errors were encountered:
You can handle this one of two ways. You can check the file metadata for sharing info, or you can just request the link and handle the error.
Checking for sharing info: https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_shared_links
$pathToFile = "/someFolder/someFile"; $response = $dropbox->postToAPI("/sharing/list_shared_links", [ "path" => $pathToFile ]); $data = $response->getDecodedBody();
$data will have a links[0].link_permissions object in it. If there is no share, links will be an empty array.
$data
links[0].link_permissions
links
Handling the error and continuing:
You can just get the share data from the error, then you don't have to make a second call.
$data = ""; try{ $pathToFile = "/someFolder/someFile"; $response = $dropbox->postToAPI("/sharing/list_shared_links", [ "path" => $pathToFile ]); $data = $response->getDecodedBody(); } catch (DropboxClientException $e) { $response = $e->getMessage(); $dataObj = json_decode($response, $assoc=true); $data = $dataObj['error']['shared_link_already_exists']['metadata']; } echo json_encode($data);
Sorry, something went wrong.
No branches or pull requests
I testing the shared link function. I generated one, but when I requests the same function I got this error:
{"error_summary": "shared_link_already_exists/.", "error": {".tag": "shared_link_already_exists"}}
How to check if shared link exists and than use that or create a link if it don't exists?
The text was updated successfully, but these errors were encountered: