# Updating Deal using API returns 400 error (Bad Request)

**URL:** <https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168>\
**Category:** APIs & Integrations\
**Tags:** object\
**Created:** [July 8, 2019, 10:12am UTC](https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168 "2019-07-08T10:12:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulAlmond91](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paulalmond91/32/48165_2.png) [@PaulAlmond91](https://community.hubspot.com/u/PaulAlmond91)\
**Post date:** [July 8, 2019, 10:12am UTC](https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168/1 "2019-07-08T10:12:01Z")

</div>

Hi,

I’m trying to make a simple PUT Request to update a Deal property using php. I’m making the following call:

```auto
$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

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [July 8, 2019, 10:37am UTC](https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168/2 "2019-07-08T10:37:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaulAlmond91](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/paulalmond91/32/48165_2.png) [@PaulAlmond91](https://community.hubspot.com/u/PaulAlmond91)\
**Post date:** [July 8, 2019, 10:45am UTC](https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168/3 "2019-07-08T10:45:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matija2209](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matija2209/32/69256_2.png) [@Matija2209](https://community.hubspot.com/u/Matija2209)\
**Post date:** [December 20, 2019, 12:45pm UTC](https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168/4 "2019-12-20T12:45:21Z")

</div>

Do you have this for Python?

---

<div class="post-metadata">

**Author:** ![Matija2209](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matija2209/32/69256_2.png) [@Matija2209](https://community.hubspot.com/u/Matija2209)\
**Post date:** [December 20, 2019, 12:50pm UTC](https://community.hubspot.com/t/updating-deal-using-api-returns-400-error-bad-request/15168/5 "2019-12-20T12:50:07Z")

</div>

Here is what I have now but it results in error 405 (Method not allowed). Do you have any ideas?

```auto
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)

```
