⚙ Operations Hub

AWeil
Member

Custom-coded-action: Merge contacts that share the same phone number

SOLVE

We are working on using the custom-coded-action “Merge contacts that share the same phone number” however when we try and use the code we are receiving the following error message. Does anyone have any ideas on what we're doing wrong?

WARNING: The logs for this function have exceeded the 4KB limit.
...
ngth\":\"316\",\"content-type\":\"application/json;charset=utf-8\",\"date\":\"Tue, 09 May 2023 13:37:09 GMT\",\"nel\":\"{\\\"success_fraction\\\":0.01,\\\"report_to\\\":\\\"cf-nel\\\",\\\"max_age\\\":604800}\",\"report-to\":\"{\\\"endpoints\\\":[{\\\"url\\\":\\\"https:\\\\/\\\\/a.nel.cloudflare.com\\\\/report\\\\/v3?s=AoQcSh%2BH5KWQpzgws3ks9CEQbHhIfvrvmDb5RqQQPkxJw6%2Bjqk6P4oHxXEEPs3JPqQtbiWQWE068mOQQWJ2qKs0T343RV26smKKgBH%2Fple%2FF4S47WDmQ%2FMQTpELWV0oi\\\"}],\\\"group\\\":\\\"cf-nel\\\",\\\"max_age\\\":604800}\",\"server\":\"cloudflare\",\"strict-transport-security\":\"max-age=31536000; includeSubDomains; preload\",\"vary\":\"origin, Accept-Encoding\",\"x-envoy-upstream-service-time\":\"3\",\"x-evy-trace-listener\":\"listener_https\",\"x-evy-trace-route-configuration\":\"listener_https/all\",\"x-evy-trace-route-service-name\":\"envoyset-translator\",\"x-evy-trace-served-by-pod\":\"iad02/hubapi-td/envoy-proxy-5677b5b686-nr69t\",\"x-evy-trace-virtual-host\":\"all\",\"x-hubspot-auth-failure\":\"401 Unauthorized\",\"x-hubspot-correlation-id\":\"98c75a82-5862-403d-b08b-d365f55dfd60\",\"x-request-id\":\"5bab5413-bf26-4744-a129-724d0c263177\",\"x-trace\":\"2B633DFCFA065BAC628DA848157B468B920A4632ED000000000000000000\"}","    at BasicApiResponseProcessor.<anonymous> (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/BasicApi.js:247:23)","    at Generator.next (<anonymous>)","    at fulfilled (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/BasicApi.js:5:58)","    at processTicksAndRejections (node:internal/process/task_queues:96:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: HTTP-Code: 401","Message: An error occurred.","Body: {\"status\":\"error\",\"message\":\"Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview\",\"correlationId\":\"98c75a82-5862-403d-b08b-d365f55dfd60\",\"category\":\"INVALID_AUTHENTICATION\"}","Headers: {\"access-control-allow-credentials\":\"false\",\"alt-svc\":\"h3=\\\":443\\\"; ma=86400, h3-29=\\\":443\\\"; ma=86400\",\"cf-cache-status\":\"DYNAMIC\",\"cf-ray\":\"7c4a55e4de5413b3-IAD\",\"connection\":\"close\",\"content-length\":\"316\",\"content-type\":\"application/json;charset=utf-8\",\"date\":\"Tue, 09 May 2023 13:37:09 GMT\",\"nel\":\"{\\\"success_fraction\\\":0.01,\\\"report_to\\\":\\\"cf-nel\\\",\\\"max_age\\\":604800}\",\"report-to\":\"{\\\"endpoints\\\":[{\\\"url\\\":\\\"https:\\\\/\\\\/a.nel.cloudflare.com\\\\/report\\\\/v3?s=AoQcSh%2BH5KWQpzgws3ks9CEQbHhIfvrvmDb5RqQQPkxJw6%2Bjqk6P4oHxXEEPs3JPqQtbiWQWE068mOQQWJ2qKs0T343RV26smKKgBH%2Fple%2FF4S47WDmQ%2FMQTpELWV0oi\\\"}],\\\"group\\\":\\\"cf-nel\\\",\\\"max_age\\\":604800}\",\"server\":\"cloudflare\",\"strict-transport-security\":\"max-age=31536000; includeSubDomains; preload\",\"vary\":\"origin, Accept-Encoding\",\"x-envoy-upstream-service-time\":\"3\",\"x-evy-trace-listener\":\"listener_https\",\"x-evy-trace-route-configuration\":\"listener_https/all\",\"x-evy-trace-route-service-name\":\"envoyset-translator\",\"x-evy-trace-served-by-pod\":\"iad02/hubapi-td/envoy-proxy-5677b5b686-nr69t\",\"x-evy-trace-virtual-host\":\"all\",\"x-hubspot-auth-failure\":\"401 Unauthorized\",\"x-hubspot-correlation-id\":\"98c75a82-5862-403d-b08b-d365f55dfd60\",\"x-request-id\":\"5bab5413-bf26-4744-a129-724d0c263177\",\"x-trace\":\"2B633DFCFA065BAC628DA848157B468B920A4632ED000000000000000000\"}","    at process.<anonymous> (file:///var/runtime/index.mjs:1189:17)","    at process.emit (node:events:513:28)","    at emit (node:internal/process/promises:140:20)","    at processPromiseRejections (node:internal/process/promises:274:27)","    at processTicksAndRejections (node:internal/process/task_queues:97:32)"]}
Unknown application error occurred
Runtime.Unknown

Memory: 25/128 MB
Runtime: 1449.04 ms
1 Accepted solution
KimM
Solution
Top Contributor

Custom-coded-action: Merge contacts that share the same phone number

SOLVE

Hi @AWeil, this looks like you've got an issue with authorisation. This could be due to how you've added the access token for your private app or because you don't have the correct scope added for this private app.

 

You'll need the crm.objects.contacts.write scope presuming you're using this API endpoint: https://legacydocs.hubspot.com/docs/methods/contacts/merge-contacts.

 

Maybe double check you've got the right scope and if that's not the issue send a screenshot of your custom code step?

View solution in original post

2 Replies 2
KimM
Solution
Top Contributor

Custom-coded-action: Merge contacts that share the same phone number

SOLVE

Hi @AWeil, this looks like you've got an issue with authorisation. This could be due to how you've added the access token for your private app or because you don't have the correct scope added for this private app.

 

You'll need the crm.objects.contacts.write scope presuming you're using this API endpoint: https://legacydocs.hubspot.com/docs/methods/contacts/merge-contacts.

 

Maybe double check you've got the right scope and if that's not the issue send a screenshot of your custom code step?

tcxen
Contributor | Platinum Partner
Contributor | Platinum Partner

Custom-coded-action: Merge contacts that share the same phone number

SOLVE

Hi @AWeil did you manage to resolve this?

 

I'm trying to do something similar and got the same error message as you.

Applied @KimM 's solution (Private App set up as a secret, the Private App has the correct scope).

 

Now getting a different error (as is the way):

 

TypeError: Cannot read properties of undefined (reading 'properties').

 

The issue it is talking about is on line 21 of this code sample: https://github.com/HubSpot/sample-workflow-custom-code/blob/main/samples/dedupe_contact.js

 

Any ideas?

0 Upvotes