APIs & Integrations

rocketman22
Member

Error using "NOT_IN" on Deals Search API method

Hello everybody,

 

I'm trying to perform a search on Deals, using the API's Search method.
The search requires 3 parameters in the filters. However, one of these parameters uses the "NOT_IN" operator, as I need the return of all deals from the conditional, except deals that are in specific dealstages, as shown in the body of the request:

 

 

 

  async function getDealByMatricula() {
    try {
        filterGroup = { 
          filters: [ 
              {propertyName: 'matricula', operator: 'EQ', value: matricula}, 
              {propertyName: 'associations.contact', operator: 'EQ', value: contactId},
              {propertyName: 'dealstage', operator: 'NOT_IN', values: ['429127', '48914296']}
            ]
        };
        const properties = ['matricula'];
        const limit = 1;
        const dealObjectSearch = { filterGroups: [filterGroup], properties, limit };
        const dealSearchResponse = await hubspotClient.crm.deals.searchApi.doSearch(dealObjectSearch);
		console.log(JSON.stringify(dealSearchResponse.body.results));
        if (dealSearchResponse.body.results.length > 0) {
          return dealSearchResponse.body.results[0].id;
        } else {
          return null;
        }
    } catch (err) {
        throw err;
    }
  }

 

 

 

When calling the method, HubSpot responds with a 400 error, with the message:
"Invalid input JSON on line 1, column 214: operator NOT_IN requires values."

 

When I use Postman, I get the expected result. I can't see where the error is.

 

Can someone help me?

 

Thanks,

0 Upvotes
2 Replies 2
rocketman22
Member

Error using "NOT_IN" on Deals Search API method

Hello @Jaycee_Lewis,

 

Thanks for the feedback!


Yes, I tried breaking the filters. Without the "NOT_IN" parameter everything works normally. The code above returns deals without problems, but of course, because it doesn't have the third parameter, it returns the wrong deals.

 

And as mentioned, when I print the request body and use it in Postman (including with the "NOT_IN" operator), the endpoint returns status 200 and I get exactly the response I need.

 

Thanks,

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Error using "NOT_IN" on Deals Search API method

Hey, @rocketman22 👋 Thanks for your question. We're you able to get this resolved? 

 

If not, have you tried breaking out the filters? To see if we can identify why it's not recognizing the array you're sending with this filter.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes