Hi,
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?
Thanks
Hello @PaulAlmond91
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 )
Thanks
Hi @himanshurauthan
Thanks for replying.
I didn’t need to reformat as I realised once you posted your example what I had done wrong.
I changed “property” to “name” and this now worked correctly.
Monday morning brain to blame!!
Thanks Again
Do you have this for Python?
Here is what I have now but it results in error 405 (Method not allowed). Do you have any ideas?
import requests
import json
url = "https://api.hubapi.com/deals/v1/deal/1291584395?hapikey=XXXX"
headers = {}
headers['Content-Type'] = 'application/json'
data=json.dumps({
"properties": [
{
"value": "TEST",
"name": "dealname"
},
{
"value": "123",
"name": "amount"
}
]
})
r = requests.post(data=data, url=url, headers=headers)