Step 1: Generate the authorization token. FortiWeb API requests can be authenticated by placing a Base64-encoded JSON object containing the administrator credentials and VDOM in the HTTP Authorization header.
On Linux or macOS, generate the encoded value with:
echo -n '{"username":"admin","password":"fortinet","vdom":"root"}' | base64
Note 1: Replace admin, fortinet, and root with the appropriate FortiWeb administrator username, password, and VDOM.
Example output:
eyJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiJmb3J0aW5ldCIsInZkb20iOiJyb290In0K
Note: Base64 encoding does not encrypt the administrator credentials. Protect the generated value as a password and use a dedicated administrator account with the minimum required permissions.
Step (2) Query the real-server status.
Use the following endpoint:
https://FortiWeb-IP/api/v2.0/policy/policystatus.detail?policy_name=PolicyName
Replace:
<FortiWeb-IP> with the FortiWeb management IP address or hostname. <PolicyName> with the server-policy name.
A curl version of the API query should look like this:
curl -k https://10.109.19.9/api/v2.0/policy/policystatus.detail?policy_name=ENRGY-TESZT -H "authorization:eyJ1c2VybmFtZSI6ImFkbWluIiwicGFzc3dvcmQiOiJmb3J0aW5ldCIsInZkb20iOiJyb290In0K"
The result should look like this:
{ "results": [ { "id": 1, "pool": "Test_pool", "name_route": "app.example.com", "type": 1, "ipDomainName": "10.109.19.30", "port": 443, "healthCheckStatus": "disable", "sessionCount": 0, "backupServer": 0, "status": 1, "server_rtt": 0, "app_response_time": 0 }, { "id": 2, "pool": "Test_pool", "name_route": "app.example.com", "type": 1, "ipDomainName": "10.109.20.8", "port": 443, "healthCheckStatus": "enable", "sessionCount": 0, "backupServer": 0, "status": 1, "server_rtt": 0, "app_response_time": 0 } ] }
POSTMAN version:
 Related article: Technical Tip: How to generate API Authorization token for FortiWeb
|