How to get external id, device id and name in one API

Our requirement is all device data(name, id and external id ) in one API.
Currently one API is Available for get external id on the basis of device ID. this is more complex suppose I have 1000 device. This device is showing in drop down menu that case 1000 times external id API will be call. But our requirement is different, external id should be one object with device details.

Please give me solution it will be help for us. Thanks in advance

Hi Rahul,

for showing devices in a dropdown box you don’t need to call the identity API. You mainly use queries for managed objects. Identity API is called when single objects should be retrieved/updated etc. If you just want to display the identifier there are multiple ways to achieve that. Easiest way is to add the identifier to the device name.
You can also store identifiers as part of the managed object by adding a custom fragment e.g. “my_extId”. There are not checks performed for uniqueness etc.

When now retrieving the devices you can use the inventory API with a query to filter specific devices (if desired).

Hi Stefan,

Do you have like any example of the mangagedObjects query API? I did’t get the storing the external ID of the device in the device mangedObjects.

I do have the same use case, I have built a custom widget where in the configuration i’m providing user to select the device from the drop down, but many devices have the same name so i thought to concat the external ID with the name for uniqueness.

To get the list of device i use something like this:

 async getDeviceList(): Promise<IResultList<IManagedObject>> {
    const filter: object = {
      pageSize: 2000,
      withTotalPages: true,
    };
    const query = {
      name: "*",
    };

    let nonee = await this.inventory.listQueryDevices(query, filter);
    for (let i = 0; i < nonee.data.length; i++) {
      this.datapoints.push(nonee.data[i])
    }
    this.ddList = this.datapoints.map((item, index) => {
      return { id: item.id, text: item.name };
    });
}

Now i con’t want to call the external id API for each device. Need help with external ID query!

Thanks,
Saif

Hi Saif,

you are on the wrong end (UI). You should do this on device registration/data ingestion.The name should be provided by the device agent so it contains already the external id.

Once stored “wrongly” you cannot much do about but just finding some hacks to query the identity API etc. to also display the external id.
Btw. you can also rename you device manually by adding the external id afterwards. For 1000s of devices a script could do that but normally this is the task of the agent to send a meaningful name (containing an unique identifier).