Bulk api V10 is not working

Hi All,
  I am facing problem with bulk api, simple example is also not working in my side, I am getting bad input data pass error. Request to you please help me on this. Right now I can't share my code with you because I am posting via mobile. Thx in advance.
  • Check you are individually json encoding each request, as well as the entire payload.
  • Hi,

    Thanks for the reply.

    Please see below my code, which I am using for v10/bulk


    <?php error_reporting(E_ALL); ini_set("display_errors", 'On'); $base_url = "">localhost:81/.../v10";   $username = "admin"; $password = "admin";  function call($url,$oauthtoken='',$type='GET', $arguments=array(), $encodeData=true, $returnHeaders=false) {     $type = strtoupper($type);      if ($type == 'GET')     {         $url .= "?" . http_build_query($arguments);     }      $curl_request = curl_init($url);      if ($type == 'POST')     {         curl_setopt($curl_request, CURLOPT_POST, 1);     }     elseif ($type == 'PUT')     {         curl_setopt($curl_request, CURLOPT_CUSTOMREQUEST, "PUT");     }     elseif ($type == 'DELETE')     {         curl_setopt($curl_request, CURLOPT_CUSTOMREQUEST, "DELETE");     }      curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);     curl_setopt($curl_request, CURLOPT_HEADER, $returnHeaders);     curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);     curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);     curl_setopt($curl_request, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));      if (!empty($oauthtoken))     {         $token = array("oauth-token: {$oauthtoken}");         curl_setopt($curl_request, CURLOPT_HTTPHEADER, $token);     }      if (!empty($arguments) && $type !== 'GET')     {         if ($encodeData)         {             //encode the arguments as JSON             $arguments = json_encode($arguments);         }         curl_setopt($curl_request, CURLOPT_POSTFIELDS, $arguments);     }      $result = curl_exec($curl_request);      if ($returnHeaders)     {         //set headers from response         list($headers, $content) = explode("\r\n\r\n", $result ,2);         foreach (explode("\r\n",$headers) as $header)         {             header($header);         }          //return the nonheader data         return trim($content);     }      curl_close($curl_request);      //decode the response from JSON     $response = json_decode($result);      return $response; } $url = $base_url . "/oauth2/token"; $oauth2_token_arguments = array(     "grant_type" => "password",     //client id/secret you created in Admin > OAuth Keys     "client_id" => "sugar",     "client_secret" => "",     "username" => $username,     "password" => $password,     "platform" => "base" ); $oauth2_token_response = call($url, '', 'POST', $oauth2_token_arguments);  // -------------------------------------******------------------------------//  $bulk_arguments = array(   "requests" => array(     array(       "url" => "/v10/Accounts",       "method" => "POST",       "data"=>"{\"name\": \"test123\"}",     ),     array(       "url" => "/v10/Contacts",       "method" => "GET",     ),   ) );  $url = $base_url . "/bulk";  $filter_response = call($url, $oauth2_token_response->access_token, 'POST', $bulk_arguments);  echo "<pre>"; print_r($filter_response); echo "</pre>";
  • I got the solution, I have changed below things in my code and it's work 
    $token = array("oauth-token: {$oauthtoken}");
    to:   
    $token = array("oauth-token:{$oauthtoken}","Content-Type: application/json"); 

    I have refered below post
    https://community.sugarcrm.com/thread/21838