This article explains how to use Postman to create multiple devices in a ground at once.
One of the common maker challenges is to automate your home. For example, monitor loudness level in your house. You’ve assembled 8 devices, and each device measures loudness of each room in your house.
Now you want to connect the devices to AllThingsTalk Maker, so you can develop neat monitoring solution for you and your family.
Instead of manually creating a device resource in Maker for each of your devices, you want to automate the process and save some precious time.
To follow the article you’ll need:
Here are the steps you will do:
Create a CSV file to specify each device name and title. It should look like this:
deviceName | deviceTitle |
---|---|
dev01 | Living room |
dev02 | Bathroom |
dev03 | Kitchen |
dev04 | Bedroom |
dev05 | Nursery |
dev06 | Kids room |
dev07 | Balcony |
dev08 | Gym |
It’s important that you use deviceName
and deviceTitle
as column names, because Postman will use those variable names.
Once in Maker, choose a ground where you will create your devices. From the left-hand side navigation select SETTINGS
page.
Copy GROUND ID and GROUND TOKEN. You’ll use those credentials to authenticate Postman client and create your devices in the ground.
If there is no Ground token generated for the ground, click
GENERATE NEW TOKEN
.
Run Postman and add API request to create a ground device using AllThingsTalk open API.
+ New Collection
Add requests
and name it, e.g. Create ground devices
POST
as the request methodapi.allthingstalk.io/ground/NYzFLolKLvHNA6D28CG0CJ6c/devices
as the URL endpointapplication/json
Bearer maker:4PhbVzqJ6rhQG0lqFwolzhqedJoxbLspD72WkOf
Under Body tab, specify device specs, e.g.:
{
"name": "{{deviceName}}",
"title": "{{deviceTitle}}",
"description": "A device for monitoring home loudness.",
"activityEnabled": true
}
deviceName
variable will use values from deviceName
column from your CSV filedeviceTitle
variable will use values from deviceTitle
column from your CSV filetests["It returns 201"] = responseCode.code === 201;
In Postman, in the top left corner select Runner
. It fires a request (or the whole collection) through a number of specified iterations.
Create ground devices
request8
Preview
; it should look like this:Run
to run the batchdeviceName
and deviceTitle
from the CSV for each row, and fire 8 requests towards AllThingsTalk APIIn Maker, you should see 8 new devices in your ground:
Now you can learn how to implement those new devices and start getting your data in Maker.