# Json via MQTT , Without External ID for the new devices

**URL:** https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105
**Category:** Forum
**Tags:** cumulocity, cumulocity-edge, device-connectivity
**Created:** [August 5, 2022, 7:17am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105 "2022-08-05T07:17:36Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![anon18601492](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon18601492](https://community.cumulocity.com/u/anon18601492)
#### Post date: [August 5, 2022, 7:17am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/1 "2022-08-05T07:17:36Z")

</div>

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`

```auto
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 ?

---

<div class="post-metadata">

### Author: ![vachaspati\_Diwevedi1](https://avatars.discourse-cdn.com/v4/letter/v/5fc32e/32.png) [@vachaspati\_Diwevedi1](https://community.cumulocity.com/u/vachaspati_Diwevedi1)
#### Post date: [August 5, 2022, 7:27am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/2 "2022-08-05T07:27:57Z")

</div>

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.

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/5/5/55832741e06c0e0fdb5e11b174c85b1cf92b60f4.png)

Hope this helps.

---

<div class="post-metadata">

### Author: ![anon18601492](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon18601492](https://community.cumulocity.com/u/anon18601492)
#### Post date: [August 5, 2022, 8:04am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/3 "2022-08-05T08:04:50Z")

</div>

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.

 ![mqtt_client_components](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/9/3/93c12587e513268a62eb4a10865a3c8127e9c48f.png)

---

<div class="post-metadata">

### Author: ![vachaspati\_Diwevedi1](https://avatars.discourse-cdn.com/v4/letter/v/5fc32e/32.png) [@vachaspati\_Diwevedi1](https://community.cumulocity.com/u/vachaspati_Diwevedi1)
#### Post date: [August 5, 2022, 9:51am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/4 "2022-08-05T09:51:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![vachaspati\_Diwevedi1](https://avatars.discourse-cdn.com/v4/letter/v/5fc32e/32.png) [@vachaspati\_Diwevedi1](https://community.cumulocity.com/u/vachaspati_Diwevedi1)
#### Post date: [August 5, 2022, 10:12am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/5 "2022-08-05T10:12:54Z")

</div>

Hi Chen,

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

ex: /inventory/managedObjects/update/12456

---

<div class="post-metadata">

### Author: ![anon18601492](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon18601492](https://community.cumulocity.com/u/anon18601492)
#### Post date: [August 8, 2022, 6:50am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/6 "2022-08-08T06:50:07Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![vachaspati\_Diwevedi1](https://avatars.discourse-cdn.com/v4/letter/v/5fc32e/32.png) [@vachaspati\_Diwevedi1](https://community.cumulocity.com/u/vachaspati_Diwevedi1)
#### Post date: [August 8, 2022, 6:53am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/7 "2022-08-08T06:53:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)
#### Post date: [February 4, 2023, 6:53am UTC](https://community.cumulocity.com/t/json-via-mqtt-without-external-id-for-the-new-devices/7105/8 "2023-02-04T06:53:27Z")

</div>

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