Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
James_T
5 years agoHelpful | Level 6
Error: options: expected array, got string - but it is an array?
I'm having trouble with an API call. It claims I send a string, but it seems to me to be an array.
This is the full error:
Error in call to API function "https://content.dropboxapi.com/2/fil...
- 5 years ago
Found the problem... the option file_categories needs to be an array as well.
James_T
5 years agoHelpful | Level 6
Below is my complete code. And here is the result:
Error in call to API function "files/search_v2": options: expected array, got string
$token = "....";
$options = array("path" => "/", "max_results" => 10);
$options["file_categories"] = "folder";
$parameters = array("query" => "searchPhrase", "options" => $options);
$headers = array(
"Authorization: Bearer $token",
'Content-Type: application/json'
);
$curlOptions = array(
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($parameters),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
);
try {
$ch = curl_init('https://api.dropboxapi.com/2/files/search_v2');
curl_setopt_array($ch, $curlOptions);
$response = curl_exec($ch);
//var_dump($response);
curl_close($ch);
} catch (Exception $e) {
trigger_error(
sprintf(
'Curl failed with error #%d: %s',
$e->getCode(),
$e->getMessage()
),
E_USER_ERROR
);
}
Some more debugging:
echo json_encode($parameters, JSON_PRETTY_PRINT);
{
"query": "cat",
"options": {
"path": "\/folder",
"max_results": 10,
"file_categories": "folder"
}
}
Error in call to API function "files/search_v2": options: expected array, got stringThat sure looks like an array to me, so I don't understand why it says it's a string...
James_T
5 years agoHelpful | Level 6
Found the problem... the option file_categories needs to be an array as well.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!