cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Empty response for /get_current_account

Empty response for /get_current_account

Lotus
Explorer | Level 4
Go to solution

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?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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

 

 

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution
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
Explorer | Level 4
Go to solution

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
Dropbox Staff
Go to solution

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

 

 

Lotus
Explorer | Level 4
Go to solution
Thanks a lot! It worked.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Lotus Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?