I am following the Zoho WorkDrive API docs to upload a file.
When I use simple PHP to post via curl:
$folderId = 'xxxx';
$token = 'xxxx';
$filepath = 'C:\\Users\\Me\\Pictures\\test-file.jpg';
$realPath = realpath( $filepath );
$content = curl_file_create( $realPath );
//the parameters$postFields = array(
'filename' => 'test.jpg', 'parent_id' => $folderId, 'override-name-exist' => 'true', 'content' => $content);
$curl_url = 'https://workdrive.zoho.com/api/v1/upload';
$curl_var = curl_init();
curl_setopt( $curl_var, CURLOPT_URL, $curl_url );
curl_setopt( $curl_var, CURLOPT_POST, 1 );
curl_setopt( $curl_var, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl_var, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $curl_var, CURLOPT_POSTFIELDS, $postFields );
curl_setopt( $curl_var, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $token, 'cache-control: no-cache') );
$response = curl_exec( $curl_var );
curl_close( $curl_var );
echo $response;
I can successfully Upload the file.
However when I use WordPress Curl:
$folderId = 'xxxx';
$token = 'xxxx';
$filepath = 'C:\\Users\\Me\\Pictures\\test-file.jpg';
$url = 'https://workdrive.zoho.com/api/v1/upload';
$realPath = realpath( $filepath );
$content = curl_file_create( $realPath );
//the parameters$postFields = array(
'filename' => 'test.jpg', 'parent_id' => $folderId, 'override-name-exist' => 'true', 'content' => $content);
$send = array( 'headers' => array( 'cache-control' => 'no-cache', 'authorization' => 'Bearer ' . $token,
),
- 'body' => $postFields
);
$response = wp_remote_post( $url, $send );
if (
is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) != 200 ) { error_log( print_r( $response, true ) );
}
return json_decode( wp_remote_retrieve_body( $response ) );
All I keep getting is:
{"errors":[{"id":"F6012","title":"Number of parameters is more than specified"}]}
My question is, what (and where) are the extra parameters that are being rejected?