# Batch updating Deals throwing Json error (PHP)

**URL:** <https://community.hubspot.com/t/batch-updating-deals-throwing-json-error-php/87940>\
**Category:** APIs & Integrations\
**Tags:** php, object\
**Created:** [August 21, 2023, 2:55pm UTC](https://community.hubspot.com/t/batch-updating-deals-throwing-json-error-php/87940 "2023-08-21T14:55:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MBridgeman](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@MBridgeman](https://community.hubspot.com/u/MBridgeman)\
**Post date:** [August 21, 2023, 2:55pm UTC](https://community.hubspot.com/t/batch-updating-deals-throwing-json-error-php/87940/1 "2023-08-21T14:55:52Z")

</div>

Hi

Trying to use Guzzle with PHP to batch update Deals.

Payload example:

`[{"id":12345678,"properties":{"dealname":"001122334455-1, Bob Smith, 0099887766"}},{"id":4657890,"properties":{"dealname":"00334455667-1, John Jones, 00665544332"}}]`

PHP code we’re using:

```lia-code-sample
 // API endpoint
 $apiEndpoint = "https://api.hubapi.com/crm/v3/objects/deals/batch/update";

 // Create a Guzzle client
 $client = new Client();

 // HubSpot API key and deal and contact IDs
 $apiKey = 'XXXX';
 $data = $deal_properties;

 // Make a POST request to associate the deal with the contact
 $response = $client->post($apiEndpoint, [
 'headers' => [
 'Authorization' => "Bearer {$apiKey}",
 'Content-Type' => 'application/json',
 ],
 'json' => $data
 ]);

```

Error received:

`{"status":"error","message":"Invalid input JSON on line 1, column 1: Cannot construct instance of `com.hubspot.apiutils.core.models.batch.BatchInput$Json` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('[{\"id\":12345678,\"properties\":{\"dealname\":\"001122334455-1, Bob Smith, 0099887766\"}},{\"id\":4657890,\"properties\":{\"dealname\":\"00334455667-1, John Jones, 00665544332\"}}`

Any clues? Am I missing something simple?

Thanks

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [August 22, 2023, 10:45pm UTC](https://community.hubspot.com/t/batch-updating-deals-throwing-json-error-php/87940/2 "2023-08-22T22:45:37Z")

</div>

Hey, @MBridgeman 👋

I have a few questions:

- Have you used something like [JSONLint](https://jsonlint.com/)? To make sure there aren’t any sneaky white spaces or other formatting issues?
- Have you tried logging the exact payload being sent to the API just before the request?
- Have you tried using the batch endpoint but only sending a single deal? To simplify things?
- Have you tried sending a simplified request using Postman?

Thanks for the additional information! — Jaycee

---

<div class="post-metadata">

**Author:** ![EHubspot](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@EHubspot](https://community.hubspot.com/u/EHubspot)\
**Post date:** [December 20, 2024, 10:01pm UTC](https://community.hubspot.com/t/batch-updating-deals-throwing-json-error-php/87940/3 "2024-12-20T22:01:57Z")

</div>

Thank you [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074)! This got me pointed in the right direction. What helped the most for me was to compare the json in the request body in my request with the json found in the cURL sample on the documentation website. This helped me find where I was creating my request incorrectly.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [December 20, 2024, 10:24pm UTC](https://community.hubspot.com/t/batch-updating-deals-throwing-json-error-php/87940/4 "2024-12-20T22:24:14Z")

</div>

Heck yes 🙌 Thanks for taking the time to let us know! — Jaycee
