In this guide we show you how to setup a test environment for executing device commands and show you how to test your commands using Postman.
If you don’t have Postman already installed on your workstation, go the official Postman site at https://www.getpostman.com/ to download your copy. The LooUQ Cloud WebAPIs work with the free version of Postman just fine.
When you launch Postman you will see it gets started by launching escape pods, distorting time-space continuum, moving satellites into position and other important API prerequisites.Once started there are only a couple steps to get started with a basic API method call.
Once you have Postman installed and ready to go you will be commanding your device in short order. Even if you have not built device commands into your IoT device application yet, there are several built in commands that you can exercise your device with.
Request Type and URL
Starting at the top of the Postman page, we will set the HTTP request type and URL. All devices commands are implemented using a HTTP GET request and the URL is structured like below:
https://webapi.loouq.com/api/devices/<deviceId or deviceName>/<commandName>?<optionalParameters>
Using the built in command below you can see what commands a device has available:
https://webapi.loouq.com/api/devices/<deviceId or deviceName>
The command above returns some basic information about the device and the commands the device supports. Commands are categorized by built-in commands (iotqiCommands) and commands you have created and registered in the IoT device application (userCommands).
|Note: The <commandName> part of the command URL above is case-sensitive. This is required for cross device compatibility. We recommend that your organization establish a casing (capitalization) rule for naming your commands. All LooUQ built-in commands are all lowercase.|
Security and Authentication
All connections with the LooUQ Cloud are authenticated and require encrypted connections. So for the LooUQ Cloud WebAPI (WebAPI) encrypted connection means HTTPS and for solid security we also require TLS v1.2 as the level of security protocol. WebAPI allows for 2 different types of credentials for authentication: username/password or APIKey/passphrase. Both of these credentials are applied to a cloud subscription.
|Username/Password||Every user of the LooUQ Cloud has a username and password pair. They use them to login to Setup, Console or other applications in the LooUQ Cloud ecosystem. If your user account is granted "command" permission to a subscription, you username/password will give you the ability to execute commands on all devices for that subscription.|
|APIKey/Passphrase||Optionally, you can create an APIKey for a subscription to act as a proxy for the devices in a subscription. The advantage to using an APIKey is that your account password that has other powers is not encoded in API scripts or applications. APIKeys can only be used with WebAPI.|
Steps for Authentication
- Click on the Authorization tab for your test session in Postman as shown below.
- Choose Basic Authentication (this is an HTTPS conversation so your password will not be clearly visible on its way to our servers).
- Enter your credentials (Username or APIKey).
To get started you do not need to setup any headers or set the body.
From within Postman, if you have completed the entries above you should be ready to click the blue Send button and get your results. Within one or two seconds you should see your results (shown here is the basic get command info results).