APIs & Integrations

ABirkeland
Member

Get all tickets between date1 and date2 for company with companyId xxx

SOLVE

Hi!

 

Im working for my company on retrieving all tickets for a given company we work for, and i also have to filter on dates. 

 

What i have in the body-field now is:

 
{
    "filterGroups":[
        {
        "filters": [
            {
            "propertyName""createdate",
            "operator""LT",
            "value""2021-05-30T05:48:58.447Z"
            },
            {
            "propertyName""createdate",
            "operator""GT",
            "value""2021-04-30T05:48:58.447Z"
            }
        ]
        }
    ],
    "sorts": [
      {
        "propertyName""createdate",
        "direction""DESCENDING"
      }
    ],
    "after"0
}
 
As you see i dont filter on company ID, but im guessing it has something to do with 
 "associations.company.companyId".
 
 
Thanks in advance!
0 Upvotes
1 Accepted solution
dennisedson
Solution
Community Manager
Community Manager

Get all tickets between date1 and date2 for company with companyId xxx

SOLVE

@ABirkeland 

If you are looking for a specific company to filter on, you will need to add it to the filter group

as such:

{
  "propertyName": "associations.company",
  "operator": "EQ",
  "value": "companyID"
}

where companyID == the actual id of the company. 

Another issue you will want to address is your timestamp.  You will need to convert to milliseconds.

Example of a full request:

{
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "createdate",
                    "operator": "LT",
                    "value": "1622347200000"
                },
                {
                    "propertyName": "createdate",
                    "operator": "GT",
                    "value": "1590811200000"
                },
                {
                    "propertyName": "associations.company",
                    "operator": "EQ",
                    "value": "5394153652"
                }
            ]
        }
    ],
    "sorts": [
        {
            "propertyName": "createdate",
            "direction": "DESCENDING"
        }
    ],
    "after": 0
}

HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.

View solution in original post

1 Reply 1
dennisedson
Solution
Community Manager
Community Manager

Get all tickets between date1 and date2 for company with companyId xxx

SOLVE

@ABirkeland 

If you are looking for a specific company to filter on, you will need to add it to the filter group

as such:

{
  "propertyName": "associations.company",
  "operator": "EQ",
  "value": "companyID"
}

where companyID == the actual id of the company. 

Another issue you will want to address is your timestamp.  You will need to convert to milliseconds.

Example of a full request:

{
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "createdate",
                    "operator": "LT",
                    "value": "1622347200000"
                },
                {
                    "propertyName": "createdate",
                    "operator": "GT",
                    "value": "1590811200000"
                },
                {
                    "propertyName": "associations.company",
                    "operator": "EQ",
                    "value": "5394153652"
                }
            ]
        }
    ],
    "sorts": [
        {
            "propertyName": "createdate",
            "direction": "DESCENDING"
        }
    ],
    "after": 0
}

HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.