SImple API Call

Hi guys - I am simply trying to make an API call in 1 or 2 steps and heres what I’m trying to do:

  1. Search for a contact in hubspot based on a property - Email ( I will do this on the front end)
  2. My back end will make an API call request to hubspot and if the value was found within an object or contact, then I will return the rest of the information on the front end
  3. If it is not found, then I will create a new one

This is easy with zapier, and I want to create it on my back end through Xano..

I thought it would be the READ request but the contact ID is needed to perform the operation: (GET/crm/v3/objects/contacts/{contactId})

The SEARCH request seems like it would work, and I can get a 200 request in whcih is sees the object, but I cannot get it to return/show the results I’d like to (POST/crm/v3/objects/contacts/search)

Please advise on the function stack or CURL requests needed or exact API endpoint I should use to do this…

Thanks in advance - Jon

Hey @JNeal

Have you taken a look at the batch read endpoint?

Post request here: https://api.hubapi.com/crm/v3/objects/contacts/batch/read

Your body would look like this:

{
 "properties": [
 "email",
 "firstname"
 ],
 "idProperty": "email",
 "inputs": [
 {
 "id": "email@email.com"
 }
 ]
}

In the properties array, you can add whatever properties you would like returned

Hey Denis - Thank you so much for this help! This is what I was looking for!
Though I can see that it works and calls the correct properties that I
input in the hubspot test environment, I went to add the following CURL to
my connect my API on the front end and it was not able to recognize the URL
for some reason.. See below screenshot…
[image: Screen Shot 2021-04-05 at 11.08.14 PM.png]
Any ideas here? I tried removing the “archived=false” part to no avail. The
actual error that occurs when I go to initialize the call is that it says
“URL is not correct”…
Thanks in advance - Jon

Hey @JNeal

That screengrab did not come through. Mind trying again :grinning_face:

attached

Hey Denis - Quick followup here…

How can I “update a contact” in the following manner..

Search hubspot using the “email” value to find the contact… then update a contact property with the value?

thanks - Jon

Hi @JNeal

Have you happened across this endpoint? Seems to fit the bill :grinning_face:

Thanks for this Denni! Where has that developer page been at :slightly_smiling_face:

I’ve been working off this one and that endpoit was not listed - Accounts Dashboard | HubSpot

@JNeal

Apologies for that…The legacy docs are slowly being migrated into the newer developer docs as the APIs are upgraded. Don’t worry that they are under a legacy domain name! They are stable and fully supported unless explicitely indicated

No problem and yes that endpoint seems tot be the right one, however, I am gettign 400 error that doesnt make sense.. This is the error message provided by the back end… I have everything I can think of configured correctly but it says that the “property cannot be missing or null”… Above in the request we can see that the “phone number” field has a value there, so im not sure which property it is referrring to? The contact with that email is in hubspot and its jsut not passing along the phone #… Any ideas?

As requested here is the json - I removed the api key…

Here is the raw request:

{“request”:{“url”:“https://api.hubapi.com/contacts/v1/contact/email/XANO@XANOPOST.COM/profile?hapikey=(REMOVED)",“method”:“POST”,“headers”:\["POST /contacts/v1/contact/email/XANO@XANOPOST.COM/profile?hapikey=(REMOVED) HTTP/2”,“Host: api.hubapi.com”,“accept-encoding: gzip, deflate”,“content-type: application/json”,“accept: application/json”,“content-length: 37”],“params”:“{\“properties\”:{\“phone\”:\“7742125654\”}}”},“response”:{“headers”:[“HTTP/2 400”,“date: Sat, 19 Jun 2021 20:15:52 GMT”,“content-type: application/json;charset=utf-8”,“content-length: 120”,“cf-ray: 661f6e8f8f5a2cb3-ORD”,“strict-transport-security: max-age=31536000; includeSubDomains; preload”,“vary: Accept-Encoding”,“cf-cache-status: DYNAMIC”,“access-control-allow-credentials: false”,“cf-request-id: 0ac7836db500002cb3b8a06000000001”,“expect-ct: max-age=604800, report-uri=\”[https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\\](https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\)“”,“x-hubspot-correlation-id: 854a27da-26f7-459e-9abb-8c56a2948490”,“x-hubspot-ratelimit-daily: 500000”,“x-hubspot-ratelimit-daily-remaining: 499999”,“x-hubspot-ratelimit-interval-milliseconds: 10000”,“x-hubspot-ratelimit-max: 150”,“x-hubspot-ratelimit-remaining: 149”,“x-hubspot-ratelimit-secondly: 15”,“x-hubspot-ratelimit-secondly-remaining: 14”,“x-trace: 2BB11EC654FEF4487E6E074E1EB9A8F823FC771BAA000000000000000000”,“report-to: {\“endpoints\”:[{\“url\”:\“https:\\/\\/a.nel.cloudflare.com\\/report\\/v2?s=47g5mhhMI9qMnSBYjhFMmUUJptINvhBgkUdOJGst2tSX5qKfwnsbNuKq1RUt2%2FPrMJi%2FoEQC1xKjsLHIfIGb4FWvvpiMJ4Go2VxSW0e%2FeujV86BUlEWXSyuh0A%3D%3D\”}],\“group\”:\“cf-nel\”,\“max_age\”:604800}”,“nel: {\“report_to\”:\“cf-nel\”,\“max_age\”:604800}”,“server: cloudflare”,“alt-svc: h3-27=\”:443\“; ma=86400, h3-28=\”:443\“; ma=86400, h3-29=\”:443\“; ma=86400, h3=\”:443\“; ma=86400”],“result”:{“status”:“error”,“message”:“property cannot be missing or null”,“correlationId”:“854a27da-26f7-459e-9abb-8c56a2948490”},“status”:400}}

Here is how we have the body set up in XANO (the back end platform)

Any thoughts Denis?

@JNeal , Sorry for leaving you hanging. Was out on vacation. Did you get this resolved?

Yes figured it out thanks!

My back end guys just said that you had your code arrannged in a weird way, so he had to change a few things to get it to work but seems to work as planned