How to get the managedobjectcollection of all devices

What product/components do you use and which version/fix level are you on?

Cumulocity IOT

Is your question related to the free trial, or to a production (customer) instance?


What are you trying to achieve? Please describe it in detail.

I am getting the managedobjectfilter like below. I want to get all the device’s managedobjects
I know there is an option to get all the pages and iterate through the pages.

InventoryFilter inventoryFilter = new InventoryFilter();

ManagedObjectCollection managedObjectsByFilter = inventoryApi.getManagedObjectsByFilter(inventoryFilter);
List allObjects = Lists.newArrayList(managedObjectsByFilter.get(2000).allPages());

How to use the managedObjectsByFilter.getNextPage(BaseCollectionRepresentation)
In this case how to instantiate BaseCollectionRepresentation? I tried like below and passed the baseCollectionRep inside getNextPage(). But am getting null in that case. I want to get all the available pages or anything more than 2000.

BaseCollectionRepresentation baseCollectionRep = new ManagedObjectCollectionRepresentation();

Kindly help.

Do you get any error messages? Please provide a full error message screenshot and log file.

Have you installed all the latest fixes for the products and systems you are using?

Hi Sethu,

you can use Iterator to do so:

 Iterator<ManagedObjectRepresentation> deviceIt = inventoryApi.getManagedObjects().get().allPages().iterator();
            while (deviceIt.hasNext()) {
                ManagedObjectRepresentation mor =;

Btw. setting the max page size of 2000 is not always a good thing as the requests per page might take very long to retrieve all objects. Keeping it the default page size might be more efficient when not all managed objects should be processed but only some with a certain condition.

1 Like

Hi Stefan,
Thank you so much. Thanks a lot. I am able to iterate through all the available managed objects without limiting the pageSize to 2000.

Thank you again !!


1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.