APIs & Integrations

AnnaKbn
Member

Batch update Contacts with 'idProperty'=>'email'

SOLVE

Hi everyone,
I'm trying to batch update Contacts through the API using 'idProperty'=>'email'  without success.  I'm using the PHP library. If I do the update with regular ids it works, but with 'idProperty' I get an error message 'Could not get some CONTACT objects, they may be deleted or not exist. Check that ids are valid.'

I tried rearranging the input and moving around 'idProperty' as I don't know which is the right syntax, but none worked for me.

$inputs = [
["idProperty" => "email", "id"=>"xxxx@example.com", "properties" => ["evt_test"=>true]]
];
$BatchInputSimplePublicObjectBatchInput = new BatchInputSimplePublicObjectBatchInput(['inputs' => $inputs]);
try {
$apiResponse = $this->client->crm()->contacts()->batchApi()->update(
$BatchInputSimplePublicObjectBatchInput
);
} catch (\HubSpot\Client\Crm\Contacts\ApiException $e) {
$this->log->logError($e->getMessage());
}


I really hope you can help me! Thanks!

1 Accepted solution
ChrisoKlepke
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

Batch update Contacts with 'idProperty'=>'email'

SOLVE

Hey @AnnaKbn , 

 

pretty sure idProperty is not available in the Batch Update endpoint. I've looked at the files of the BatchInputSimplePublicObjectBatchInput and there is no avail be parameter. It's a different story for Batch Read. 

 

Unless I'm missing something here, I'm sorry to disappoint you here.

 

Cheers, 

Chriso

View solution in original post

0 Upvotes
4 Replies 4
GordonRT
Participant

Batch update Contacts with 'idProperty'=>'email'

SOLVE

Yes that is what I ended up doing.  Which was use a query to retrieve by email to get the associated integer Id for that email.  Less than ideal but got the job done.

0 Upvotes
ChrisoKlepke
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

Batch update Contacts with 'idProperty'=>'email'

SOLVE

Hey @AnnaKbn , 

 

pretty sure idProperty is not available in the Batch Update endpoint. I've looked at the files of the BatchInputSimplePublicObjectBatchInput and there is no avail be parameter. It's a different story for Batch Read. 

 

Unless I'm missing something here, I'm sorry to disappoint you here.

 

Cheers, 

Chriso

0 Upvotes
GordonRT
Participant

Batch update Contacts with 'idProperty'=>'email'

SOLVE

Well to say the least the documentation is most misleading, extracted from:

https://developers.hubspot.com/docs/api/crm/contacts

 

Unique identifiers and deduplication

An email address is the primary unique identifier for a contact in HubSpot. For existing contacts, the contact ID is also unique and will deduplicate contacts. To update a contact via the API, you can use either the contact ID or the contact's email.

The idProperty query parameter doesn't appear on the Endpoints tab due to technical limitations, but it can be used for contacts exclusively with email. To use an email address as the unique identifier, set the idProperty as email and enter the email address in place of the contact ID. This should be set as a query parameter rather than added to the request body.

 

It would seem a reasonable expectation that the batch update would work in a similar manner by specifying 

 

],
"idProperty": "email"
}
0 Upvotes
craigcri
Member

Batch update Contacts with 'idProperty'=>'email'

SOLVE

Gordon, I'm solving the same problem now. It seems ONLY Contact ID / HubSpot Vid is the only way to do it... but we don't have HubSpot Contact IDs stored locally. 

 

Did you have to update to run a contact lookup to retrieve integer ID, than use that to update? 

0 Upvotes