WordPress: Number of parameters is more than specified

WordPress: Number of parameters is more than specified

I am following the Zoho WorkDrive API docs to upload a file.

When I use simple PHP to post via curl:

  1. $folderId = 'xxxx';
  2. $token = 'xxxx';
  3. $filepath = 'C:\\Users\\Me\\Pictures\\test-file.jpg';
  4. $realPath = realpath( $filepath );
  5. $content = curl_file_create( $realPath );
  6. //the parameters
  7. $postFields = array(
  8. 'filename' => 'test.jpg',
  9. 'parent_id' => $folderId,
  10. 'override-name-exist' => 'true',
  11. 'content' => $content
  12. );

  13. $curl_url = 'https://workdrive.zoho.com/api/v1/upload';
  14. $curl_var = curl_init();
  15. curl_setopt( $curl_var, CURLOPT_URL, $curl_url );
  16. curl_setopt( $curl_var, CURLOPT_POST, 1 );
  17. curl_setopt( $curl_var, CURLOPT_RETURNTRANSFER, 1 );
  18. curl_setopt( $curl_var, CURLOPT_SSL_VERIFYPEER, 0 );
  19. curl_setopt( $curl_var, CURLOPT_POSTFIELDS, $postFields );
  20. curl_setopt( $curl_var, CURLOPT_HTTPHEADER, array(
  21. 'Authorization: Bearer ' . $token,
  22. 'cache-control: no-cache'
  23. ) );
  24. $response = curl_exec( $curl_var );
  25. curl_close( $curl_var );
  26. echo $response;

I can successfully Upload the file.

However when I use WordPress Curl:

  1. $folderId = 'xxxx';
  2. $token = 'xxxx';
  3. $filepath = 'C:\\Users\\Me\\Pictures\\test-file.jpg';
  4. $url = 'https://workdrive.zoho.com/api/v1/upload';
  5. $realPath = realpath( $filepath );
  6. $content = curl_file_create( $realPath );
  7. //the parameters
  8. $postFields = array(
  9. 'filename' => 'test.jpg',
  10. 'parent_id' => $folderId,
  11. 'override-name-exist' => 'true',
  12. 'content' => $content
  13. );

  14. $send = array(
  15. 'headers' => array(
  16. 'cache-control' => 'no-cache',
  17. 'authorization' => 'Bearer ' . $token, ),
  18. 'body' => $postFields
  19. );

  20. $response = wp_remote_post( $url, $send );
  21. if (
  22. is_wp_error( $response ) ||
  23. wp_remote_retrieve_response_code( $response ) != 200 ) {
  24. error_log( print_r( $response, true ) );
  25. }
  26. return json_decode( wp_remote_retrieve_body( $response ) );

All I keep getting is:

  1. {"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?