Searching Asset customfields

Hi All,

I’m using RT-5.0.0.

I have been trying to get this to work and to some extend it does. I’m using Postman to build the json queries and the basic stuff all works but this part I can’t get it to work.
This is the body that I’m using:
[
{
“field”: “Catalog”,
“value”: “2”
},
{
“field”: “CPU”,
“value”: “Core 1”,
“entry_aggregator”: “AND”
}
]
CPU is a customfield and its value is indeed ‘Core 1’. Strange thing is if I don’t use the second set then I get all assets returned that are in Catalog with id 2. If I replace the field CPU with id and the value with 3 I’ll get the asset which has a customfield with CPU=Core 1.
So core fields seem to work but customfields don’t.

Anyone done this and would like to share how its done?

Thanks,

Joop

I’m replying to myself because I get mail from the mailinglist but replying to it doesn’t show up over here and other replies don’t show here either, weird.

On 28-11-2020 19:39, knation via Request Tracker Community Forum wrote:

45x45 knation
November 28

You should be able to use the asset query builder web UI to build your query and then provide that to the REST2 interface
Assets search does not accept ticketSQL according to the docs on bestpractical.com only the json syntax. I tried several incantation and location but can’t get anything useful from it.
This is wat the Advanced search show: Catalog = ‘Klant’ AND CF.{CPU} LIKE ‘Core 1’ and it returns 1 asset, number 3
This is what I think the json body should be (this returns all assets in Catalog 2):
[
{
“field”: “Catalog”,
“value”: “2”
}
]

Extending it to:
[
{
“field”: “Catalog”,
“value”: “2”
},
{
“field”: “CPU”,
“value”: “Core 1”,
“entry_aggregator”: “AND”
}
]
Should show asset number 3 but it shows all 3 assets that are in Catalog 3. CPU is a customfield

The following shows asset 3:
[
{
“field”: “Catalog”,
“value”: “2”
},
{
“field”: “id”,
“value”: “3”,
“entry_aggregator”: “AND”
}
]

Just to show the other options I’ll past the curl command that Insomnia generates, this one works, see above.
curl --request POST
–url ‘https://rt.example.com/REST/2.0/assets/?token=1-14-abcdefghijklmn&=
–header ‘Content-Type: application/json’
–data ‘[
{
“field”: “Catalog”,
“value”: “2”
},
{
“field”: “id”,
“value”: “3”,
“entry_aggregator”: “AND”
}
]’

And this one doesn’t, show all 3 assets in Catalog 2
curl --request POST
–url ‘https://rt.example.com/REST/2.0/assets/?token=1-14-abcdefghijklmn&=
–header ‘Content-Type: application/json’
–data ‘[
{
“field”: “Catalog”,
“value”: “2”
},
{
“field”: “CPU”,
“value”: “Core 1”,
“entry_aggregator”: “AND”
}
]’

Thanks,

Joop