Skip to main content

(API) How can I do a query and only get back “In Service” assets? I know how to do the query but cannot seem to figure out how to do the filter.

@SPenland 4671c29 gilmer Thank you for submitting your question to our community! 😄

Another API question for you ​@jclark! In the meantime, I am reaching out to our API Masters so see what information I can grab for you! 


@SPenland 4671c29 gilmer Alright, our API masters have gotten back to me and this is their recommendation: “For this one we'd recommend setting up a custom view to filter on the status of "In Service" and then use the API to pull that view.” 

While I do not full understand how the API works, for the filter, if you go through the custom view, it should show the assets only selected under that filter of “in Service”


When trying to Get Assets by View using a GET request:

 

https://SCHOOL.incidentiq.com/services/assets/view/VIEW_ID

I get “404 -Not Found”.

 

If I do

https://SCHOOL.incidentiq.com/services/assets/views/VIEW_ID

I get the return of the View only (no assets)

 

How exactly can I get the API to return the assets of a view? I’m either misreading the API documentation or there may be a mistake in it. 


Good Afternoon ​@SPenland 4671c29 gilmer 

I hope you are doing well so far today! 

I wanted to reach out today to help assist with obtaining an API call in order to pull the assets associated with a Custom Asset View. 

For this call, you will want to make the API POST call to the following URL below with {SITE} replaced with the site for your district:

URL: https://{SITE}.incidentiq.com/api/v1.0/assets/?%24s=20&%24o=AssetTag%20ASC' 

Along with this URL, you will also need to supply the following Body for the call as well with {VIEWID} replaced with the specific ViewID for the Custom View you would like:

{"OnlyShowDeleted":false,"Filters":i{"Facet":"View","Id":"{VIEWID}"}],"FilterByViewPermission":true}

With that said though, if you may still be encountering issues using this call, please let me know! 

Best Regards,
Drew


@SPenland 4671c29 gilmer Thank you for submitting your question to our community! 😄

Another API question for you ​@jclark! In the meantime, I am reaching out to our API Masters so see what information I can grab for you! 

I apologize, I missed this completely lol.

You can do this with a view like ​@athaxton_iiQ described.

Alternatively, if you don’t want to create a custom view and have it lingering…

POST to:

https://{site}.incidentiq.com/api/v1.0/assets?$s=200

(?$s=200 is the number of results per page, you may need to adjust this or account for paging in your script, depending on the number of assets you have)

 

With a payload of:

  {
"Filters":
{
"Facet": "assetstatus",
"Id": {AssetStatusTypeId},
"GroupIndex": 0
}
]
}

 

 

To get a list of AssetStatusTypeId’s…


GET from

https://{site}.incidentiq.com/api/v1.0/assets/status/types


 


Reply