cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Empty response for /get_current_account

Explorer | Level 4

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
Highlighted

Re: Empty response for /get_current_account

Dropboxer
Dropboxer

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
Highlighted

Re: Empty response for /get_current_account

Dropboxer
Dropboxer
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.
Highlighted

Re: Empty response for /get_current_account

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?

 

Highlighted

Re: Empty response for /get_current_account

Dropboxer
Dropboxer

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

Highlighted

Re: Empty response for /get_current_account

Explorer | Level 4
Thanks a lot! It worked.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?