APIs & Integrations

webcitron
メンバー

Tickets API search endpoint - sort by updatedAt

解決

I'm trying to use endpoint `POST /crm/v3/objects/tickets/search` and receive list of tickets sorted by updatedAt descending. I've tried many combinations of "sorts" property but my tries seems to be ignored by API. Documentation does not contains so many informations about how "sorts" parameter should be used. 

Anyony could give me any clue about that ?

0 いいね!
1件の承認済みベストアンサー
ChehakWadhdwa
解決策
メンバー | Diamond Partner
メンバー | Diamond Partner

Tickets API search endpoint - sort by updatedAt

解決

Hey @webcitron 

 

Could you please try using the below property

{

"propertyName": "hs_lastmodifieddate",

"direction": "DESCENDING"

}

 

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

元の投稿で解決策を見る

0 いいね!
7件の返信
ChehakWadhdwa
メンバー | Diamond Partner
メンバー | Diamond Partner

Tickets API search endpoint - sort by updatedAt

解決

Hey @webcitron

 

Can you try the below curl code

curl https://api.hubapi.com/crm/v3/objects/tickets/search?hapikey=YOUR_HUBSPOT_API_KEY \

  --request POST \

  --header "Content-Type: application/json" \

  --data '{

    "sorts": [

      {

        "propertyName": "lastmodifieddate",

        "direction": "DESCENDING"

      }

    ]

  }'



Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 いいね!
webcitron
メンバー

Tickets API search endpoint - sort by updatedAt

解決

 

@ChehakWadhdwa , thanks a lot of involvement. Please check out below listings. I've tried with 3 different payloads, all of them resulting with same (and not expected) ordering or the tickets. 

Script just executing api call and displaying "updatedAt" property for each returned ticket (its displays them in the order as they came from api):


```

$ curl -s --location --request POST 'https://api.hubapi.com/crm/v3/objects/tickets/search' --header 'Content-Type: application/json' --header 'Authorization: Bearer pat-na1-***' --data-raw '{
"limit": 5,
"sorts": [
{
"propertyName": "lastmodifieddate",
"direction": "DESCENDING"
}
]
}' | jq '.results[] | .updatedAt'
"2022-09-14T04:09:53.553Z"
"2022-09-14T04:09:53.562Z"
"2022-08-08T09:55:56.104Z"
"2022-09-14T04:09:53.553Z"
"2021-10-25T09:27:37.640Z"

 

$ curl -s --location --request POST 'https://api.hubapi.com/crm/v3/objects/tickets/search' --header 'Content-Type: application/json' --header 'Authorization: Bearer pat-na1-***' --data-raw '{
"limit": 5,
"sorts": [
{
"propertyName": "updatedAt",
"direction": "DESCENDING"
}
]
}' | jq '.results[] | .updatedAt'
"2022-09-14T04:09:53.553Z"
"2022-09-14T04:09:53.562Z"
"2022-08-08T09:55:56.104Z"
"2022-09-14T04:09:53.553Z"
"2021-10-25T09:27:37.640Z"

 

$ curl -s --location --request POST 'https://api.hubapi.com/crm/v3/objects/tickets/search' --header 'Content-Type: application/json' --header 'Authorization: Bearer pat-na1-***' --data-raw '{
"limit": 5,
"sorts": [
{
"propertyName": "updatedat",
"direction": "DESCENDING"
}
]
}' | jq '.results[] | .updatedAt'
"2022-09-14T04:09:53.553Z"
"2022-09-14T04:09:53.562Z"
"2022-08-08T09:55:56.104Z"
"2022-09-14T04:09:53.553Z"
"2021-10-25T09:27:37.640Z"

```

 

0 いいね!
ChehakWadhdwa
メンバー | Diamond Partner
メンバー | Diamond Partner

Tickets API search endpoint - sort by updatedAt

解決

Hey @webcitron

 

Looking at the results you got :

It's fetching the results based on recent results modifies.

Could you please elaborate exactly what you want with the API ? How you want the data to come ?

 

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 いいね!
webcitron
メンバー

Tickets API search endpoint - sort by updatedAt

解決

@ChehakWadhdwa , its not. look at updatedAt values which are returned by API (orginal ordering): 

```

"2022-09-14T04:09:53.553Z" (row1)
"2022-09-14T04:09:53.562Z" (row2)
"2022-08-08T09:55:56.104Z" (row3)
"2022-09-14T04:09:53.553Z" (row4)
"2021-10-25T09:27:37.640Z" (row5)

```

 

Note year and month especially. Expected return should be:

```

"2022-09-14T04:09:53.562Z" (row2)

"2022-09-14T04:09:53.553Z" (row1)

"2022-09-14T04:09:53.553Z" (row4)
"2022-08-08T09:55:56.104Z" (row3)
"2021-10-25T09:27:37.640Z" (row5)

```

 

Just reminding - im trying to fetch tickets ordered/sorted by updatedAt property value descending

 

 

ChehakWadhdwa
解決策
メンバー | Diamond Partner
メンバー | Diamond Partner

Tickets API search endpoint - sort by updatedAt

解決

Hey @webcitron 

 

Could you please try using the below property

{

"propertyName": "hs_lastmodifieddate",

"direction": "DESCENDING"

}

 

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

0 いいね!
FSoto8
参加者

Tickets API search endpoint - sort by updatedAt

解決

doestn work.

 

the response is the same without order. 

0 いいね!
webcitron
メンバー

Tickets API search endpoint - sort by updatedAt

解決

Yes, thats works 🙂 Thanks a lot @ChehakWadhdwa 🍻

0 いいね!