How to use the REST API on the BB-400 with the web application POSTMAN

FAQs

The BB-400 provides a REST server implementation that can be used to receive and modify information. This FAQ will explain how POSTMAN, a REST API client can be used to access and change information regarding the IO line status on the BB-400.

POSTMAN is one of a number of software’s used for API testing and development. The POSTMAN application is free to download for individuals and small teams.

Install the POSTMAN application

The first step is to install the POSTMAN application (https://www.getpostman.com/downloads/), and then to launch the POSTMAN app. The initial screen should look something like this:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Initial-Screen.png

GET requests

To see the status of the IO lines we can select the option to create a new GET request. GET requests allow the user to retrieve information without modifying the original information, even if the requests are sent multiple times.
To GET the current IO status of the BB-400, enter the IP address of the BB-400 followed by a colon ( : ), the port number the REST API server is running on (which in our case is 9000), as well as appending the path “/io” and click on Send. The POSTMAN application will retrieve or GET the IO status from the BB-400:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-Postman-App-GET-IO-Status.png

The following examples show that by choosing the appropriate path, one can filter the relevant information to obtain or GET information regarding the IO lines.

1. To get the input states of the IO lines:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Get-IO-Inputs.png

2. To get the input state of a selected IO line:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Get-Input-Selected-IO.png

3. To get the output states of the IO lines:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Get-IO-Outputs.png

4. To get the output state of a selected IO line:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Get-Output-Selected-IO.png

POST request

Next we might want to change the output values of the BB-400 IO lines. A POST request allows the user to modify the original information.

To configure the POSTMAN application to send POST commands, change the request from GET to POST. Then, underneath “Body”, the “raw” option should be selected and the input type should be changed to JSON (application/json).

Now, the POST requests can be entered in the Body section and clicking the Send button will send the POST request. After sending the POST requests, it is possible to see the change in IO output values reflected in the LED state on the front of the BB-400 device and via the status or IO pages of the BB-400’s web based interface. If the POST request is successful a “200 OK” status will be returned, otherwise an unsuccessful status code will appear:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Post-Config.png

1. To set the output states of the IO lines

To set the output states of all the IO lines, the data should be set as a JSON array:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-chrome-web-browser-Postman-Post-IO-Output-State.png

The web admin IO page shows that the POST request closed all the outputs:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-Postman-App-Webadmin-IO-status-1.png

2. To set the output state of a selected IO line

To set the output state of an individual IO line, first change the path to the line required, then send a POST command:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-Postman-App-POST-IO-Select-IO-Output-0.png

The web admin IO page can also be checked:

files/pages/support/faqs/bb-400-faqs/How-to-use-the-REST-API-on-BB400-from-Postman-App-POST-IO-Select-IO-Output-0-WebAdmin.png

This FAQ has described how POSTMAN, a REST API can be used to receive and modify the status of the IO lines. A few examples of how to use the GET and POST commands have been provided to show the user how the REST server implementation works using the BB-400 IO line status.



FAQs