The CSO HTTP APIs are available through endpoints to which a user can send HTTP requests. For each operation that maps to a remote procedure call (RPC), the request pattern is as follows:
This article describes how to execute CSO HTTP Rest API's using Postman API client. The provided example is based on CSO 5.1.2. This KB is provided as example instructions for Postman.
Launch the Postman desktop client and click on Settings
Make sure the Settings, especially 'SSL certificate verification' and 'Retain Headers when clicking links' are adjusted as shown below:
As mentioned in KB34116 [juniper.net] the first step is to get the token to authenticate further CSO Rest API requests.
Tokens can be generated in different ways:
Generate a token:
URL: http://CSO IP Address:5000/v3/auth/tokens CSO IP Address => CSO VIP IP if CSO deployed in HA mode or CSO baremetal server IP if CSO deployed in standalone mode
Content-Type = applicatoin/json Used Json body as shown in examples below depending on token scope.
Global scoped token:
{ "auth": { "scope": { "project": { "domain": { "id": "default" }, "name": "admin" } }, "identity": { "password": { "user": { "domain": { "id": "default" }, "password": "$ABC123", "name": "cspadmin" } }, "methods": [ "password" ] } } }
{ "auth": { "scope": { "project": { "domain": { "id": "default" }, "name": "TenantA" } }, "identity": { "password": { "user": { "domain": { "id": "default" }, "password": "$ABC123", "name": "user@router" } }, "methods": [ "password" ] } } }
Example:
Select the Headers tab in the response output and copy the 'X-Subject-Token' key value as shown in the output below.
Click Save button to save the API with a specific name to reuse in the future.
Once the token is generated, you can send various CSO HTTP Rest API requests (GET, POST, DELETE etc) as shown below:
CSO IP Address => CSO VIP IP if CSO deployed in HA mode or CSO baremetal server ip if CSO deployed in standalone mode namespace => microservice name object => name of object exposed under microservice http namespace
Accept = application/Json X-AUTH-TOKEN = Paste the token value retrieved in Step 4