Mender API List Device Inventories

Hi,

I’m currently in the process of rewriting the GitHub Action for deployments so that it can also deploy to dynamic groups from within an Action. While working on this, I noticed the following issue:

From the endpoint https://hosted.mender.io/api/management/v1/inventory/devices it is not possible, as described in the documentation, to filter by attributes (tags). On my device, the following tag is set:

qa=true

However, it is not possible to filter all devices with the qa=true attribute using this endpoint. The response from the REST API is always empty.

Its also not possible to use the example attributes attr_name_1=foo&attr_name_2=100to filter the results.

RESPONSE=$(curl -s -X GET "https://eu.hosted.mender.io/api/management/v1/inventory/devices?qa=true" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer $PAT")

echo $RESPONSE | jq -r '.[] | {id, hostname: (.attributes[]? | select(.name=="hostname") | .value)}'

I am using the eu.mender.io API endpoint, maybe it is somehow different from the mender.io version?

Was already answered Device Inventory API: Search by tags

Solution: /api/management/v1/inventory/devices?tags/attr_name_1=true

Should be added to the API documentation….

EDIT:
If you want to chain tags you will need to use this:
/api/management/v1/inventory/devices?tags/foo=bar#foo1=bar1

1 Like