Hello,
I am writing a simple app that creates some folders when we add a new client to our systems.
I keep getting an error:
Error in call to API function "files/create_folder_batch": Bad HTTP "Content-Type" header: "application/json; boundary=------------------------0e03e86aa71fa792". Expecting one of "application/json", "application/json; charset=utf-8", "text/plain; charset=dropbox-cors-hack".
Here is the code that I am using:
function create_folders() {
$ch = curl_init();
$folders = array(
"/B - Client Folders/" . $folder_name,
"/B - Client Folders/" . $folder_name . "/Logo",
"/B - Client Folders/" . $folder_name . "/Photos",
"/B - Client Folders/" . $folder_name . "/Graphics"
);
$params = array(
$folders,
'"autorename":false',
'"force_async":false');
curl_setopt($ch, CURLOPT_URL, 'https://api.dropboxapi.com/2/files/create_folder_batch');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer <key>',
'Dropbox-Api-Path-Root: {".tag": "namespace_id", "namespace_id": "<nsid>"}',
'Content-Type: application/json'));
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {echo $result;}
curl_close($ch);
}
I don't understand why "; boundary=------------------------0e03e86aa71fa792" is being added to "application/json".
Thanks for your help in advance.