Json via MQTT , Without External ID for the new devices

Dear Team,
I tried to create devices with Json via MQTT, and found the external can’t be saved into database. Then the new measurement can’t be sent to target device with MQTT.

topic: /inventory/managedObjects/create

Json Payload: 
{
	"name": "JSON_MQTT_GATEWAY",
	"c8y_IsDevice": { },
	"c8y_DeviceTypes": [
		"C8Y_MQTT"
	],
	"c8y_SupportedOperations": [
		"c8y_Restart"
	],
	"c8y_Serial":[
		"aecc14f1-ca34-48a3-926c-14832afcb0d3"
	]
}

Question: How to specific the external ID for new devices in Json via MQTT ?

Hi Chen,

When you configure the MQTT connection, then you have to specify the client Id and that would be the external Id for that connection and any device you create using that connection

If you have to create a new device with different external Id, I would suggest you to create a separate connection with new external id and then create the device using json payload.

Hope this helps.

Hi Diwevedi,
I am also testing with MQTTBox, the Client Id is generated automatically.
I remove the ‘c8y_Serial’ property for the device json. But the External Id is still missed.

Hi Chen,

If you use the topic “/inventory/managedObjects/create” with JSON payload it won’t add the external id since it’s internally directly invoking the Inventory API to create ManageObject.

I will suggest to first create your device using standard topic “s/us” and command “100,DeviceName,DeviceType”, This will create the device (ManagedObject) and associate the external Id with it.

next you can update the JSON Payload using the same connection but the topic “/inventory/managedObjects/update” and JSON payload

Hi Chen,

One correction-
The topic name to update the JSON payload would be “/inventory/managedObjects/update/{{ManagedObjectID}}”

ex: /inventory/managedObjects/update/12456

Thanks, it’s available to update the MO with topic “/inventory/managedObjects/update/{{ManagedObjectID}}”.
But it should not be available to update external id, right ?

I will suggest to first create your device using standard topic “s/us” and command “100,DeviceName,DeviceType”, This will create the device (ManagedObject) with the external ID.

Next step is to update the managed Object as mentioned above.