We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
jurgenatore
6 years agoExplorer | Level 3
get_temporary_link and could not decode input as JSON
Hello.
I'm trying to get a temporary link for file with using get_temporary_link from file_properties with below listed PHP code:
$getlink_url = 'https://api.dropboxapi.com/2/files/get_temporary_...
- 6 years ago
The /2/files/get_temporary_link endpoint is an RPC-style endpoint, so it expects the API call parameters as JSON in the request body.
In the code you shared, you're actually sending the parameters in a header named 'data'.
You'll need to fix your code to send them in the request body, like:
$parameters = json_encode( array ( "path"=>"/file_storage/some_file.zip" ) );
curl_setopt($ch1, CURLOPT_POSTFIELDS, $parameters);
Greg-DB
6 years agoDropbox Staff
The /2/files/get_temporary_link endpoint is an RPC-style endpoint, so it expects the API call parameters as JSON in the request body.
In the code you shared, you're actually sending the parameters in a header named 'data'.
You'll need to fix your code to send them in the request body, like:
$parameters = json_encode( array ( "path"=>"/file_storage/some_file.zip" ) );
curl_setopt($ch1, CURLOPT_POSTFIELDS, $parameters);
- jurgenatore6 years agoExplorer | Level 3
Greg
Thank you very much for support. Now works fine:
$getlink_url = 'https://api.dropboxapi.com/2/files/get_temporary_link'; $getlink_headers = array ( 'Authorization: Bearer '. $token, 'Content-Type: application/json' ); $ch1 = curl_init($getlink_url); $parameters = json_encode( array ( "path"=>"/file_storage/some_file.zip" ) ); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch1, CURLOPT_POSTFIELDS, $parameters); curl_setopt($ch1, CURLOPT_HTTPHEADER, $getlink_headers); $response2 = curl_exec($ch1); curl_close($ch1); error_log($response2);
Best, Michal
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months agoIf 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!