RESTful API configuration and support on cnMaestro

 Overview:

A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. Currently cnMaestro On-Premises support API version 1 (v1) with HTTP requests to GET, PUT and POST. This API allows users to read data and perform operations programmatically using their own client applications. The API is supported over HTTPS, and messages are exchanged in JSON format.

The OAuth2.0 RESTful API supports device monitoring data for ePMP, PMP, and Wi-Fi, including Wi-Fi Clients. The API includes inventory, statistics, event, and alarm data.

Architecture:

1.png

A basic OAuth2 API session is presented below. The client retrieves an Access Token to start the session. It sends API requests until the Access Token times out, at which point the token can be regenerated.

This document will provide information on integrating API client (Postman) application to cnMaestro On-Premises to query required details.

Postman is available as a chrome extension and as an individual application.

https://www.getpostman.com/

https://chrome.google.com/webstore/category/extensions

Steps followed:

  1. OAuth 2.0 Access credentials Client ID and Client Secret are created while API Client is added on cnMaestro.
  2. Using these Access credentials on API Client (Postman) Access Token is generated.
  3. Using the Access Token further querying of details by GET, PUT and POST happens from Postman to cnMaestro.

Configuration on cnMaestro On-Premises:

On cnMaestro GUI navigate to Services >> API Clients and click on Add API Client.2.png

Enter details to add API Client, with Name, Description, Expiration Time (Default is 3600 =1 hour), Concurrent Access of Access Tokens. Save the configuration.

3.png

Upon Saving the configuration, OAuth 2.0 Access Credentials are generated, Copy Client ID and Client Secret4.png

We can also download the Access Credentials using Download Credentials option which will give in Json format file.

{
  "application_name": "TestAPI",
  "application_description": "Testing",
  "client_id": "DOkn68AB4tji5lD1",
  "client_secret": "KiPJCETaFBnLGEakmgNS6HlmhlnJOq"
}

Configuration on API Client (Postman) Application:5.png

Open Postman application in your computer select Authentication Type as OAuth 2.0 and click on Get New Access Token.6.png

Fill the details to get new Access Token. Token Name, Access Token URL, Client ID, Client Secret and select Grant Type : Client Credentials. Click on Request Token.

7.png

Access Token gets generated for the request. Choose Add Token to : Header and click on Use Token.8.png

Now you can see as the Access Token under Header field.9.png

Query based on your requirement, in this case we have performed a GET for the clients connected, click on Send and output is displayed in the Body.

10.png

Compare the output from cnMaestro GUI:11.png

HTTP Response codes12.png

Refer to available APIs supportability in the API Reference GUI.

https://support.cambiumnetworks.com/files/cnmaestro/

2 Likes