Check for existence of managedObjects and c8y_Position fragment

Hi I wanted to check if the managedObject exists or not and also if it has the c8y_Position fragment ?
I have tried the following code but as it does not return anything how can I check it ?
if(managedObjectRepresentation.getProperty(“c8y_Position”)) {
}

Hi @rushikesh_n ,

I assume you are using Java and the Microservice SDK.

For those checks I would recommend to use an appropriate query against the inventory API.

If you still want to check this locally only:

Check out the other available methods of the ManagedObjectRepresentation class.
You can use the hasProperty method, to check if the object contains the required fragment.

Regards
Kai

1 Like

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