How to create a new device using http request

Hi, I am trying to create a new device through an http request, I attach the code that I use to assign variables to an already created device

//Dart code on flutter–Post method to send a data

String url =
http://industrial.api.ubidots.com/api/v1.6/devices/DEVICE_LABEL/’;
String body = ‘{“Variable_Label”: “Data”}’; // Body of Post
int length = body.length;

Map<String, String> headers = { //Header of Post
“X-Auth-Token”: “Auth_Token”,
“Content-Type”: “application/json”,
“Content-Length”: “$length”,
};
Response response = await post(url,headers: headers, body: body); Send Post Request
print(response.statusCode);

How could I adapt it to create a new device instead of sending a variable? Thanks

Hi @DaniloGb,

thanks for sharing your question with the community.

Following up, in order to create a new device just use that same request with an empty body, that way our backend will create the devices without any variable.

You can also refer to our documentation to know how to create a Device using our most recent API v2.0 version.

Best,
–Sergio.