Update contact batch


#1

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

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"
      }
    ]
  }
]

#3

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