APIs & Integrations

SAMsan
Contributor

About Custom Code

SOLVE

Hello,

 

I'm strugling with custom code blocks, wondering if there's any limitation that could be related to my issue, knowing this search returns 2 matching results on Postman.
I'm trying to get deals with this search query:

let myFilters =[{
propertyName: "dealstage",
operator: "EQ",
value: `${dealStage}`
},
{
propertyName: "associations.contact",
operator: "EQ",
value: `${contactId}`
}];
// Get all deals for this contact or return
let deals = hubspotClient.crm.contacts.searchApi.doSearch({filterGroups: [{filters: myFilters}] })
.then((response) => {
console.log( response.total );
})

Here is the resulting error log:

WARNING: The logs for this function have exceeded the 4KB limit.
...
IC\",\"cf-ray\":\"7cbe4b6429be2d0b-IAD\",\"connection\":\"close\",\"content-length\":\"123\",\"content-type\":\"application/json;charset=utf-8\",\"date\":\"Tue, 23 May 2023 15:22:28 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=5Ay%2Fc1Tr3MJRht7TykYA7B0%2BNvB7cb0bjY9LOFbUX2VKZlt6YCUtNrWMaUPZvGoohh5VCnmm34v2LeXHrOGes7t5cnul2zaR%2FMaS2eOXuQ%2FJRv7Sj6P%2F8owwst2LgblA\\\"}],\\\"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\":\"142\",\"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-598c95b5b7-vk5c8\",\"x-evy-trace-virtual-host\":\"all\",\"x-hubspot-correlation-id\":\"c70f4345-5b27-4449-87f7-f28751624478\",\"x-hubspot-ratelimit-daily\":\"500000\",\"x-hubspot-ratelimit-daily-remaining\":\"488248\",\"x-request-id\":\"4a42f223-df0b-4f16-ba48-3255ef8e8264\",\"x-trace\":\"2B79D33B70A50AAD3E7CCE0D04EF4B2B5ECDA3C8CB000000000000000000\"}","    at SearchApiResponseProcessor.<anonymous> (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/SearchApi.js:63:23)","    at Generator.next (<anonymous>)","    at fulfilled (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/contacts/apis/SearchApi.js:5:58)","    at processTicksAndRejections (node:internal/process/task_queues:96:5)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: HTTP-Code: 400","Message: An error occurred.","Body: {\"status\":\"error\",\"message\":\"There was a problem with the request.\",\"correlationId\":\"c70f4345-5b27-4449-87f7-f28751624478\"}","Headers: {\"access-control-allow-credentials\":\"false\",\"alt-svc\":\"h3=\\\":443\\\"; ma=86400, h3-29=\\\":443\\\"; ma=86400\",\"cf-cache-status\":\"DYNAMIC\",\"cf-ray\":\"7cbe4b6429be2d0b-IAD\",\"connection\":\"close\",\"content-length\":\"123\",\"content-type\":\"application/json;charset=utf-8\",\"date\":\"Tue, 23 May 2023 15:22:28 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=5Ay%2Fc1Tr3MJRht7TykYA7B0%2BNvB7cb0bjY9LOFbUX2VKZlt6YCUtNrWMaUPZvGoohh5VCnmm34v2LeXHrOGes7t5cnul2zaR%2FMaS2eOXuQ%2FJRv7Sj6P%2F8owwst2LgblA\\\"}],\\\"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\":\"142\",\"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-598c95b5b7-vk5c8\",\"x-evy-trace-virtual-host\":\"all\",\"x-hubspot-correlation-id\":\"c70f4345-5b27-4449-87f7-f28751624478\",\"x-hubspot-ratelimit-daily\":\"500000\",\"x-hubspot-ratelimit-daily-remaining\":\"488248\",\"x-request-id\":\"4a42f223-df0b-4f16-ba48-3255ef8e8264\",\"x-trace\":\"2B79D33B70A50AAD3E7CCE0D04EF4B2B5ECDA3C8CB000000000000000000\"}","    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: 79/128 MB
Runtime: 2750.20 ms

 

0 Upvotes
1 Accepted solution
SAMsan
Solution
Contributor

About Custom Code

SOLVE

OK, my bad, searching the crm.contacts with a deal query will never work...

// Get all deals for this contact or return
let deals = hubspotClient.crm.contacts.searchApi.doSearch({filterGroups: [{filters: myFilters}] })

  Thank you @Jaycee_Lewis for your time!

View solution in original post

0 Upvotes
2 Replies 2
SAMsan
Solution
Contributor

About Custom Code

SOLVE

OK, my bad, searching the crm.contacts with a deal query will never work...

// Get all deals for this contact or return
let deals = hubspotClient.crm.contacts.searchApi.doSearch({filterGroups: [{filters: myFilters}] })

  Thank you @Jaycee_Lewis for your time!

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

About Custom Code

SOLVE

Hey, @SAMsan 👋 Thanks for your question! I have some questions that will help the community better understand your project and its goal(s).

  • Have you tried converting the dealStage and contactId variables to strings? Something like this? 
    value: `${dealStage.toString()}`
  •  Since it works in Postman, can you share your request and request body from Postman here?
  • Are you hardcoding dealStage and contactId in your Postman request?

Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes