Impossible to add device with REST API?

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

Cumulocity IOT 1015.0.244

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

production

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

Add a device using REST API (/inventory/managedObjects) with Postman : when I send the POST request, i have a 201 with some informations as name, internal ID but nothing appears in Device list (on Web interface -GUI).

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

No error from REST API.

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

No update.

I’m guessing you are not flagging it as a device and the c8y_IsDevice fragment is missing in the payload?
Can you share your payload you are sending to confirm this?

In order for a managed object to be recognized as device it needs the c8y_IsDevice fragment. You can learn more about this and other important data in devices here: Device management library - Cumulocity IoT Guides

You can also add an “Accept” header to your POST request, then Cumulocity will return the created object as a response. You can find the documentation about it here: Cumulocity IoT - OpenAPI Specification

1 Like

If I use the example from your documentation :

{
    "name": "RaspPi BCM2708 0000000017b769d5",
    "type": "c8y_Linux",
    "c8y_IsDevice": {},
    "com_cumulocity_model_Agent": {},
    "c8y_SupportedOperations": [ "c8y_Restart", "c8y_Configuration", "c8y_Software", "c8y_Firmware" ],
    "c8y_Hardware": {
        "revision": "000e",
        "model": "RaspPi BCM2708",
        "serialNumber": "0000000017b769d5"
    },
    "c8y_Configuration": {
        "config": "#Fri Aug 30 09:13:56 BST 2013\nc8y.log.eventLevel=INFO\n..."
    },
    "c8y_Mobile": {
         "imei": "861145013087177",
        "cellId": "4904-A496",
        "iccid": "89490200000876620613"
    },
    "c8y_Firmware": {
        "name": "raspberrypi-bootloader",
        "version": "1.20130207-1"
    },
    "c8y_Software": {
        "pi-driver": "pi-driver-3.4.5.jar",
        "pi4j-gpio-extension": "pi4j-gpio-extension-0.0.5.jar"
   
    }
}

Then the response with 201 status is :

{
    "additionParents": {
        "references": [],
        "self": "https://<<domain>>/inventory/managedObjects/164688/additionParents"
    },
    "owner": "<<user>>",
    "childDevices": {
        "references": [],
        "self": "https://<<domain>>/inventory/managedObjects/164688/childDevices"
    },
    "childAssets": {
        "references": [],
        "self": "https://<<domain>>/inventory/managedObjects/164688/childAssets"
    },
    "creationTime": "2023-03-10T16:24:15.349Z",
    "type": "c8y_Linux",
    "lastUpdated": "2023-03-10T16:24:15.349Z",
    "childAdditions": {
        "references": [],
        "self": "https://<<domain>>/inventory/managedObjects/164688/childAdditions"
    },
    "name": "RaspPi BCM2708 0000000017b769d5",
    "deviceParents": {
        "references": [],
        "self": "https://<<domain>>/inventory/managedObjects/164688/deviceParents"
    },
    "assetParents": {
        "references": [],
        "self": "https://<<domain>>/inventory/managedObjects/164688/assetParents"
    },
    "self": "https://<<domain>>/inventory/managedObjects/164688",
    "id": "164688",
    "c8y_Firmware": {
        "name": "raspberrypi-bootloader",
        "version": "1.20130207-1"
    },
    "c8y_Mobile": {
        "iccid": "89490200000876620613",
        "imei": "861145013087177",
        "cellId": "4904-A496"
    },
    "c8y_Software": {
        "pi4j-gpio-extension": "pi4j-gpio-extension-0.0.5.jar",
        "pi-driver": "pi-driver-3.4.5.jar"
    },
    "com_cumulocity_model_Agent": {},
    "c8y_IsDevice": {},
    "c8y_Configuration": {
        "config": "#Fri Aug 30 09:13:56 BST 2013\nc8y.log.eventLevel=INFO\n..."
    },
    "c8y_SupportedOperations": [
        "c8y_Restart",
        "c8y_Configuration",
        "c8y_Software",
        "c8y_Firmware"
    ],
    "c8y_Hardware": {
        "serialNumber": "0000000017b769d5",
        "model": "RaspPi BCM2708",
        "revision": "000e"
    }
}

Which tenant?

Can you display device with id 164688 in the UI (pick an existing device and replace its idin the url with 164688)?

Is there a filter active on your Device-List? (referring to the list shown in Device Management > Devices > All Devices)

I tried but I have an error.
c8y_bug

I just have 10 devices. Even after rebooting, problem is still present.

yes, thanks. But I have no filter.

Can you check that the X-Cumulocity-Processing-Mode header is not set within your POST request? see: Cumulocity IoT - OpenAPI Specification
Can you also check if you are able to retrieve the device via Postman? So a GET to /inventory/managedObjects/164688.

2 Likes

Also make sure to check your credentials especially the tenant when doing the REST request.
I could also be that you creating the devices in a different tenant as you expect because of the credentials.

Thanks for your support : X-Cumulocity-Processing-Mode was “TRANSIENT”. When I remove it, it’s working fine.

I was using your definition ( OpenAPI Specification) to import into Postman. The problem is that the request POST comes with X-Cumulocity-Processing-Mode:TRANSIENT.

1 Like

Maybe @Philipp_Emmel can comment on the reason to support TRANSIENT for managed objects.

The problem you are facing seems to be at least partially a Postman problem. In the OpenAPI specification, PERSISTENT is the default value and TRANSIENT is the example value. It seems like Postman uses the latter when you import a OpenAPI specification. I have suggested internally that we change the example value to PERSISTENT as well to avoid similar confusion.

1 Like

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