Retrieve Multiple Deals By Account Number

HDOlsen
Contributor

Good day,

 

      I am trying to make a .Net request to https://api.hubapi.com/crm/v3/objects/deals/search to retrieve a variable number of deal objects using "account number" as the search property.  The problem is that I do not know how many accounts must be returned- maybe 2, maybe 500.   I have already tried to pass in a request body with >40 JSON objects in the "Filter" array, but receive a 'Bad request.  Maximum number of filters is 3." message.  Is there a way around this?  I thank you so much!

9 Replies 9
dennisedson
Community Manager

@MichaelC , do you have any advice on how to tackle this one?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
MichaelC
Guide | Partner

@HDOlsen 

 

Hello 👋

 

Can you explain a bit further so that I get a clear sense of understanding.

 

Is account number a custom made property? Or is account number an object (such as deals, contacts, tickets and companies)?

 

Lets say account number is a custom made property - several deals (up to 500 or so) may have the same account number?

Do you want all deals with a specific account number or should it be all deals with a specific account number and also other requriements met?

 

Give me some more details and Ill gladly help out 🤗

 

M



Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

MichaelC
Guide | Partner

@HDOlsen 

 

There are a few errors in your code - I dont know if you put them there on purpose or not so I will give you the full explaination. 

 

In hubspots world the pipeline and dealstage have uniqe ID numbers. Since we can create an infinite amount of pipelines and an infinite amount of deal stages all get a uniqe ID. 

 

You need to enter the id number of the pipeline and the id number of the dealstage under "value" in your code. 

 

 

To get the pipeline internal ID:

In your hubspot account - go to settings - submenu Data Management then click Deals. Within deals click Pipelines.

Within pipelines select the pipeline "accounts". And then click the </> to get the pipelines internal value.

MichaelC_0-1621270006673.png

 

To get the dealstage internal ID:

In the same settings - hover the mouse over the dealstage "Openfunded" to get its internal value:

(ignore the fact that my deal stages are named differently in my example)

MichaelC_1-1621270226174.png

 

 

 

Valid operators:

You may only use the operators listed here:

https://developers.hubspot.com/docs/api/crm/search

IN is not on the list what I can see. 

MichaelC_2-1621270505693.png

 

Searching several objects in one go:

In order to search a list as you want you have to setup different filters.

The example is shown here:

https://developers.hubspot.com/docs/api/crm/search

 

And picture (with my drawing here:)

MichaelC_3-1621270667162.png

 

MichaelC_4-1621270831866.png

 

 

Michael

 

 

 



Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

HDOlsen
Contributor

@MichaelC 

 

   Thank you, Michael.  I was indeed able to GET the pipeline and deal stage with your help.  However, your suggested approach to searching many objects resulted in the following error:  

{
    "status""error",
    "message""too many filterGroups (count: 4, max allowed: 3)",
    "correlationId""c65164df-132a-4373-b4f8-d511822d450b",
    "category""VALIDATION_ERROR"
}
 
  It appears using the EQ operator cannot accomodate the number of requests we anticipate.  FYI I was able to use the IN operator but it only returns partial results (i.e. some deals are not being returned even though they have matching account_number):
 
{"filters": [{"propertyName""account_number""operator""IN""values": ["09001gg501""GFG453gg068""072134dd51""WHaa032818""F067ad03966""97259007550""FFI76975gg9""CSA03332gg4"] }, {"propertyName""pipeline""operator""EQ""value""20159466"}, {"propertyName""dealstage""operator""NEQ""value""29826001"}], "properties":["dealstage""account_number""dealname"], "limit"100}  returns
 
{
    "total"1,
    "results": [
        {
            "id""52578883w205",
            "properties": {
                "account_number""CSA03332gg4",
                "createdate""2020-05-13T21:24:37.431Z",
                "dealname""Mr. Fowl RTY Roth IRA",
                "dealstage""",
                "hs_lastmodifieddate""2020-05-14T14:19:51.015Z",
                "hs_object_id""525793320ww5"
            },
            "createdAt""2020-05-13T21:24:37.431Z",
            "updatedAt""2020-05-14T14:19:51.015Z",
            "archived"false
        }
    ]
}
MichaelC
Guide | Partner
You are right. I read the documentation and it clearly states three filters per filter group. But I think you can have more filter groups with three filters each (but you only need two in each).

So instead of doing my way above do it "one row in" and create a big amount of filter groups.

Tell me if its unclear and I will try to give you a code example. (On my phone now so earliest tomorrow).

M


Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

HDOlsen
Contributor

Sorry, I edited the above because the account numbers are sensitive.  I would love to speak with you tomorrow.

himanshurauthan
Recognized Expert | Platinum Partner

Yes, this is the limitation of the Search API that you can pass a maximum of 3 filters at a time. I can see you're quite close to finding a solution but I would like to add a suggestion too. So based on your accounts maybe you can break requests into a group of 3?

 

Regards,

Digital Marketing & Inbound Expert In Growth Hacking Technology
MichaelC
Guide | Partner
i have sent a PM to try to fix the last part of this issue over an online meeting. Will get back with the official solution here


Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

HDOlsen
Contributor

I appreciate your help gentlemen.  We came up with a solution, so all is okay.  I'll continue to monitor the forum in case you add new features.  Thanks again, and until then! Hutson