[SOLVED] Create device with API with behavior not expected

Hello!
I’m creating end-user devices with API. Only after this “pre configuration” end-user hardware will be able to send dots to its organization.

My commands use this configurations:
topic: http://industrial.api.ubidots.com/api/v1.6/datasources/?token=<organization_token>&type=<device_type>
payload:
{
“name”: “Device1”,
“description”: “Mary’s Device1”,
“context”: {
“version”: “v3.1-dev-661-gf586f5e6”,
“MAC”: “B4:E6:2D:BF:61:E1”
},
“tags”: [
“Internal”,
“tinyDevice_v1”
]
}

WIth HTTP post command, I get return code 201 and the device is created.

But, there are 3 situations:

  1. its Label is assigned to “Internal”, the first Tags item, instead of “name”;
  2. the context items are not added to the device, none of them; and
  3. it does not create the variables configured on the device type.

Is this HTTP post command correct? Should it work properly? That is, use “name” to create the “label”, create all context items and create the device type variables?

Best regards,

Cristiano.

Greetings, you are using a wrong endpoint. Once you finish a device type creation, you can see an example http request like the one below:

curl -X POST 'https://industrial.api.ubidots.com/api/v1.6/devices/{your-device-label}/?type={YOUR_DEVICE_TYPE_LABEL}' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: TOKEN' \
-d ''

From the above example, the endpoint that you should use is industrial.api.ubidots.com/api/v1.6/devices instead the one that you are using in your actual request.

About the device label, you have to setup the device label inside the endpoint as shown in the example. Additionally, device types do not support name and description value keys as they are already setup once you create your device type, while context and tags are not supported using its endpoint, if you need to configure them you will have to make a PATCH to the device once created using the request structure specified here.

Hope this clarifies your doubt.

All the best,