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

Lotus's avatar
Lotus
Explorer | Level 4
7 years ago

Empty response for /get_current_account

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",

     

     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff
    I see that you're getting a response with a 400 status code, which means that the call failed. The response body should contain a more useful error message, so you should print it out.

    You're setting 'CURLOPT_NOBODY => true' though, so curl won't return the body. Disable that to retrieve the body.
    • Lotus's avatar
      Lotus
      Explorer | Level 4

      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?

       

      • Greg-DB's avatar
        Greg-DB
        Icon for Dropbox Staff rankDropbox Staff

        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",

         

         

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,888 PostsLatest Activity: 24 hours ago
326 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!