Apr 10, 2018 8:00 AM
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( array( 'objectId' => deal-id1, 'properties' => array( array( 'name' => 'dealstage', 'value' => 'b091bb57-c9fe-4224-a73f-4a36e5a9ee9d' ) ) ), array( 'objectId' => deal-id2, 'properties' => array( 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); //print_r(curl_getinfo($ch));die; $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curl_errors = curl_error($ch); curl_close($ch); echo "curl Errors: " . $curl_errors; echo "\nStatus code: " . $status_code; echo "\nResponse: " . $response;
any help would be appreciated.
Thanks in advance.
Apr 10, 2018 10:44 AM
@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.