Question

Can I search the FreshService assets API via asset_tag OR Name OR Hostname?

  • 10 January 2023
  • 2 replies
  • 385 views

Badge

Hello,

 

I’m trying to figure out whether its possible to query the FreshService API for a specific asset based on multiple fields. Apologies if this isn’t the correct place to ask this question!

 

In our environment some computers are often missing either their asset tag, name (aka display name) or hostname field. In a perfect world, all three fields would be identical for every asset, however as this isn’t the case, I need a way to query for an asset across all three fields. 

Is it possible to query for an asset that matches on ANY of those fields. Similar to the way the FreshService search works in the UI of the inventory page?

According to the documentation here, the only fields supported on the search endpoint are;

  • name
  • asset_tag
  • serial_number

Is there any other way of doing this search via the API in a single query?

 

Any help would be much appreciated.

 

Thanks,

M


2 replies

Badge

Hi @mbft did you ever get this working? I’m running into a similar issue and would love to know if you found a solution.

thanks!

Badge

Hi @mmardini13 

The closest thing I could get to doing this in a single query was;

api/v2/assets?filter="name: 'DEVICE_NAME' OR asset_tag: 'DEVICE_TAG' " 

 

From my experience this query doesn’t work for partial searches. 

According to the documentation the assets endpoint doesn’t support filtering by serial number which does kinda make sense.

It would however potentially make a query like I originally enquired about possible using multiple logical OR’s for serial, name and tag. https://api.freshservice.com/#filter_assets

Reply