Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi,
some years ago I used the dropbox Api v1 and now I try to switch to v2.
I managed to get the authorization done but now I'm struggeling with the /get_current_account endpoint.
my php looks like that:
public static function dropboxAuthorize($token) { $curl = curl_init(); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt_array($curl, array( CURLOPT_URL => "https://api.dropbox.com/2/users/get_current_account", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_NOBODY => true, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 50, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_HTTPHEADER => array( "authorization: Bearer " . $token, "cache-control: no-cache", "content-type: application/json" ), )); $response = curl_exec($curl); }
The response is empty! Not false or anything else. I get no erros and don't know what's wrong.
If I send the request via Postman I get the correct response.
This is my var_dump of the response and curl_getinfo:
string(0) "" Array ( [url] => https://api.dropbox.com/2/users/get_current_account [content_type] => text/plain; charset=utf-8 [http_code] => 400 [header_size] => 394 [request_size] => 259 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.273269 [namelookup_time] => 3.3E-5 [connect_time] => 0.004135 [pretransfer_time] => 0.017209 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => 0 [starttransfer_time] => 0.27322 [redirect_time] => 0 [redirect_url] => [primary_ip] => 162.125.66.7 [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 46.38.241.53 [local_port] => 50110 )
Can someone help me pls?
That error is indicating that the request body couldn't be parsed as JSON. This endpoint doesn't have any required parameters, so you can just specify:
CURLOPT_POSTFIELDS => "null",
Thanks for your response!
I thought this option would mean that I send no request body to the server and not that I don't get one...
If I disable this option I get the following error:
string(103) "Error in call to API function "users/get_current_account": request body: could not decode input as JSON"
I tried to google that problem but couldn't find any helpful information.
Could you help me again?
That error is indicating that the request body couldn't be parsed as JSON. This endpoint doesn't have any required parameters, so you can just specify:
CURLOPT_POSTFIELDS => "null",
Hi there!
If you need more help you can view your support options (expected response time for a 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!