APIs & Integrations

Polou
Member

Update contact batch

Hello,

I’m using batch API to update more than 1 contact at same time.
Example :

$contacts = [
        [
            'email' => "test1.test1@test.com",
            [
                ['property' => 'login_demo', 'value' => 'test1.test1@test.com],
                ['property' => 'pass_demo', 'value' => 'test'],
                ['property' => 'trial_start_date', 'value' => 1483228800000],
                ['property' => 'trial_end_date', 'value' => 1483228800000],
            ]
        ],
        [
            'email' => "test2.test2@test.com",
            [
                ['property' => 'login_demo', 'value' => 'test2.test2@test.com'],
                ['property' => 'pass_demo', 'value' => 'test'],
                ['property' => 'trial_start_date', 'value' => 1483228800000],
                ['property' => 'trial_end_date', 'value' => 1483228800000],
            ]
        ],
    ];

Then i call https://api.hubapi.com/contacts/v1/contact/batch with $contacts array.
I’m using this php wrapper : https://github.com/ryanwinchester/hubspot-php
Working great for only one contact with createOrUpdate/email/{$email}

I get 202 response “Accepted”, but when i go in the UI website to check, those 2 contacts aren’t updated… Even after waiting 20min because of async…
Can you help please ?

2 Replies 2
Polou
Member

Update contact batch

Thank you @Derek_Gervais, that solved the problem :slight_smile:

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Update contact batch

Hi @Polou,

Can you make sure that the second part of the JSON (the array) has the key properties ? The final JSON should look something like this:

[
  {
    "email":"test1.test1@test.com",
    "properties": [
      {
        "property": "login_demo", 
        "value": "test1.test1@test.com"
      },
      {
        "property": "pass_demo", 
        "value": "test"
      },
      {
        "property": "trial_end_date", 
        "value": "1483228800000"
      },
      {
        "property": "login_demo", 
        "value": "1483228800000"
      }
    ]
  },
  {
    "email":"test2.test2@test.com",
    "properties": [
      {
        "property": "login_demo", 
        "value": "test2.test2@test.com"
      },
      {
        "property": "pass_demo", 
        "value": "test"
      },
      {
        "property": "trial_end_date", 
        "value": "1483228800000"
      },
      {
        "property": "login_demo", 
        "value": "1483228800000"
      }
    ]
  }
]
0 Upvotes