0

I have devices in Cumulocity with "Mobile" fragment in them. I would like to retrieve information about a device by specifying a iccid, which is part of the "Mobile" fragment. For now I perform search in inventory based on filter: InventoryFilter inventoryFilter = new InventoryFilter().byFragmentType(Mobile.class);

and then check whether the iccid in the found devices match the required. But I would like somehow to specify iccid in the search.

Is this possible and if yes - how to do this?

Ivajlo Iliev
  • 303
  • 1
  • 3
  • 19

1 Answers1

1

Yes it is possible. You need to define a custom query similar to the query you would use via normal API call:

...?query=$filter=c8y_Mobile.iccid eq '<<your-iccid>>'

In Java you can have a custom filter class for this:

public class CustomInventoryFilter extends InventoryFilter {

@ParamSource
private String query;

public CustomInventoryFilter byQuery(final String query) {
    this.query = query;
    return this;
}

Instead of the InventoryFilter.class you use this custom class and add the same query as above into .byQuery("c8y_Mobile.iccid eq '<<your-iccid>>'")

socona
  • 432
  • 3
  • 13