Querying parent devices from child devices after object hirearchy is created using cumulocity APIs

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

The component using is the Cumulocity API.

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

Free trail

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

The cumulocity API is used to create the Object hirearchy. We are able to query the child devices from parent devices through but unable to query the parent devices from child devices.

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

In the GET Method response of the Edge Gateway(parent device), we can view the childDevice Id and childDevice URL in the references key of the childDevices nested json .

Below is the Get Method response of the InLine_Scanner. InLine_Scanner is the child device of the Parent device Edge Gateway. There is no references to the parent device of the InLine_Scanner in the deviceParents nested json .

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

yes

1 Like

Hi @prathyusha.kanda,

the reason for this behavior is the defaults of withChildren and withParents URL parameters.
By default withChildren is true, however withParents is false by default.

Hence just add withParents=true to your query and you will also see the references in deviceParents.

Please refer to the API documentation:
https://cumulocity.com/api/10.14.0/#operation/getManagedObjectResource

Regards
Kai

2 Likes