Question

Zapier App Extension and API Issue - Hubspot update contact API endpoint not working when using email as contactiD

  • 28 November 2023
  • 7 replies
  • 403 views

Related issue here, but using app extension: 

 

App Extension Issue - Hubspot update contact API endpoint not working when using email as contactid

 

Context: I am trying to create an app extension to update only the properties I use in hubspot rather than the create hubspot action step which returns all 500+ contact properties in our HubSpot environment which effectively breaks my browser and zapier editor due to the long running script.

I have scoured the hubspot API docs and hubspot community for a fix and not found anything that solves my issue even though i’ve following everything required by the api docs and suggested on the forums. 

Issue: Per hubspot API docs (https://developers.hubspot.com/docs/api/crm/contacts) it says:

Update contacts

You can update contacts individually or in batches. For existing contacts, email and record ID are both unique values, so you can use id or email to update contacts via API. If you've created a custom unique identifier property, you can also use those unique values to update contacts. When using email or a custom unique value property, include the idProperty parameter to specify the property you're using (e.g., "idProperty": "email").

To update an individual contact by its contact ID, make a PATCH request to /crm/v3/objects/contacts/{contactId}, and include the data you want to update.

I have tried both including "idProperty": "email" as a body parameter and a query parameter per these two hubspot community posts:

https://community.hubspot.com/t5/APIs-Integrations/Update-contact-with-email-as-ID-through-the-Hubspot-API/m-p/623680

https://community.hubspot.com/t5/CRM/Unable-to-Update-Contacts-Via-Email/m-p/710045

BUT - when i test out the app extension with an email that exists in my hubspot crm I get the error that the object could not be found. I really can’t figure out why and i’d prefer to not switch to just a webhook so i don’t have to bother with authentication headers etc.

 

I have reached out to hubspot support for this but haven’t heard back yet and I also booked a meeting with Lisa Orr from zapier app extension division for help but that meeting isn’t until later. 

 

 


7 replies

Userlevel 7
Badge +14

Hi @jshurtleff33 

Good question.

Perhaps try this approach…

Add a Zap step to find the contact by email to get the Contact ID, then use the Contact ID.

 

Hey @Troy Tessalone 

Assuming I did that and had the VID to work with I then just tested the extension with a sample Record ID from an existing contact got the same response. I even tried setting the contactId data type on the extension set up as string, text, integer, and number and all of them returned an error during execution.

 

Were you able to test and reproduce my problem and get it to work on your end?  

 

 

 

Userlevel 7
Badge +14

@jshurtleff33 

Another option to try would be to use this Zap action: HubSpot - API Request

 

Update - I was able to get the extension to work when using the contact VID and having {{contactId}} in the URL instead of {contactId} (single vs double curly brackets). I’ll use this for now but for some reason when I add the "idProperty": "email" query or body param it returns invalid URL so it appears something about the URL encoding from zapier that is going on is not working or the hubspot API is broken at the "idProperty": "email"

query param variation of the /crm/v3/objects/contacts/{contactId} end point  endpoint.

Userlevel 7
Badge +11

That’s great news @jshurtleff33! Thanks so much for sharing details of how you were able to resolve the issue with the contactID being incorrectly referenced in the URL. 😁🎉

With the second issue, judging by the examples in the HubSpot API documentation it seems to expect to receive the idProperty within the body of the request, not appended to the URL as a query parameter. When you remove the idProperty settings from the Query Parameters section and just have it included as a body parameter do you get the exact same error about the URL being invalid?

If you get a different error could you share a screenshot of that here? Thinking that error might contain details that help us to better identify what changes you might need to make to fix it. Thanks, looking forward to hearing from you!

This post has been edited by a moderator to remove personal information. Please remember that this is a public forum and to remove any sensitive information prior to posting.

@SamB I get the following error when I use "idProperty": "email" as body parameter in the json block which to me inplies that it’s not picking it up in the body as an alert to the API to use an email as the idProperty. The only other option is to then use it as a url query param which isn’t working either. Quite the conundrum. I’ve presented this information to hubspot support and am waiting to hear back.

 

If you or someone could try to recreate either of these errors or get it to work as a query or body parameter please update this thread, it would go a long way to helping the community and myself understand this issue. 

 

 

 

Userlevel 7
Badge +11

Thanks for sending over those helpful screenshots @jshurtleff33! 🙂

I’ve been doing some further digging and came across this thread in the HubSpot community here which seems to suggest that adding the email address and the idProperty directly into the URL of the request should work:

“I don't think idProperty=email works on the batch request. 

 

I was able to reproduce your problem.

 

When I used the single PATCH update for a contact using the email address as the contact ID. The API worked.

 

/crm/v3/objects/contacts/tstemail@gmail.com?idProperty=email

 

My guess is because BATCH wants the contact ID to make the updates faster and not have to search by email. (Just a guess).”


So can you try removing the reference to the idProperty in the Body field and instead of adding it into the Query Parameters fields, just update the URL to:

https://api.hubapi.com/crm/v3/objects/contacts/{contactId}?idProperty=email

Just thinking that maybe adding it into the Query Parameters fields was partly causing it to not be added to the URL in the exact way that HubSpot was expecting. 

And also, can you try updating the Body of the request to something more like this:

{
"inputs": [
{
"id": "{{contactId}}",
"properties": {
"lender_lead_status": "{{lender_lead_status}}"
}
}
]
}


I can’t guarantee these changes will work but thought it worth exploring just in case that does the trick. Please keep us updated on how that goes, I’m very keen to know whether or not that solves it! 🤞

Reply