Updating Deal using API returns 400 error (Bad Request)SOLVE
Jul 8, 2019 6:12 AM
I'm trying to make a simple PUT Request to update a Deal property using php. I'm making the following call:
$apikey = $config->hapikey; $url = 'https://api.hubapi.com/deals/v1/deal/864835248?hapikey=' . $apikey; $data = ["properties" => [ [ "property" => "company_name_hidden", "value" => "test" ] ] ]; $options = array( 'http' => array( 'method' => 'PUT', 'content' => json_encode($data), 'header'=> "Content-Type: application/json\r\n" . "Accept: application/json\r\n" ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); $hubcomp = json_decode($result, true); return $hubcomp; }
I am receiving a 400 bad request but I've double checked the formatting and cannot identify the cause.
Can anyone point out where this is causing the error?
Solved! Go to Solution.
Jul 8, 2019 6:37 AM
Can you please try as per this method?
$properties = array( "name" => "company_name_hidden", "value" => "test" );
$dealDetails = array( "properties" => $properties );
I think there is a issue in the array $data that you have formed ( used wrong keys )