Unable to update a group of deals



Hello guys,

I am trying to update a group of deals as explained in hubspot's doc - https://developers.hubspot.com/docs/methods/deals/batch-update-deals and i have created the same json format as expected but getting empty errors , 405 status code and empty response. i have a list of deal ids created in hubspot and i am using the below code:

$arr = array(
   'objectId' => deal-id1,
            'properties' => array(
                    'name' => 'dealstage',
     'value' => 'b091bb57-c9fe-4224-a73f-4a36e5a9ee9d'                    
   'objectId' => deal-id2,
            'properties' => array(
                    'name' => 'dealstage',
     'value' => 'b091bb57-c9fe-4224-a73f-4a36e5a9ee9d'                    
        $post_json = json_encode($arr); 
 // print_r($post_json);die;  
        $hapikey = 'my-key';
        $endpoint = 'https://api.hubapi.com/deals/v1/batch-async/update?hapikey='.$hapikey;
        $ch = curl_init();
      //  curl_setopt($ch, CURLOPT_POST, true);    
        curl_setopt($ch, CURLOPT_URL, $endpoint);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $curl_errors = curl_error($ch);
        echo "curl Errors: " . $curl_errors;
        echo "\nStatus code: " . $status_code;
        echo "\nResponse: " . $response;

any help would be appreciated.

Thanks in advance.


@kalpana790 Can you please share with me the full response you are getting from HubSpot?


below is the response:

curl Errors:
Status code: 405


@kalpana790 I'll need to be able to see the raw response from HubSpot. Should be in your terminal. A 405 is generally METHOD not allowed. It looks like you are making a PUT request where you should be making a POST request.