REST API includes the following request and response types:
Simple Request
In a standard POST or PUT API request, the parameters are passed in a string with a key:value pair. For example, a request for adding a service would be:
curl http://10.36.73.160:8000/restapi/v3.2/services -X POST -H Content-Type:application/json -u 'eyJldCI6IjmFkbWluIn0=\n:' -d
'{
"name": "demo_service_3",
"ip_address": "10.11.16.176",
"port": "80",
"type": "http",
"address_version": "ipv4",
"vsite": "demo_vsite",
"group": "demo_vsite_group"
}'
Fetching data using the group filter
A query parameter called “groups” can be included with REST API GET requests to filter the response to a specific configuration group. The available values for the group parameter for each of the API objects can be found in the GET request documentation for that object.
For example, the available values that can be passed to the groups parameter for the “services” API are provided in the screenshot below:
Following is an example of a GET request to fetch all the services from the Barracuda WAF with the response filtered to only include the URL ACLs information:
Example:
curl -X GET "http://<WAF-IP/WAF-Domain>:8000/restapi/v3.2/services?groups=URL ACLs" -H "Content-Type: application/json" -u “token:”
Fetching data using the category filter
A query parameter called “category” with the value set to “operational” can be included with REST API GET requests to filter the response to the operational status of the API object.
Fetching data using the limit and offset filters
These filters are mostly used with the logging API objects such as /web-firewall-logs, /audit-logs, /access-logs and /system-logs
By default, the API response for any of the log type objects will have 20 logs. More logs can be fetched using the Pagination(limit & offset) support.
curl -X POST http://10.36.73.160:8000/restapi/v3.2/logs/web-firewall-logs?limit=20&offset=40 -u "eyJldNkNjQzNjZiOGUxNDQ2OTM4ZjRkIn0=\n:"
Fetching data using the parameter filter
A query parameter called “parameters” can be included with REST API GET requests to filter the response to the specified parameters.
curl -X GET "http://10.36.73.160:8000/restapi/v3.2/services?parameters=app-id" -H "Content-type: application/json" -u "eyJldCzNjZiOGUxNDQ2OTM4ZjRkIn0=\n:"
Response Types
The following table lists the different response codes :
Response Code | Description |
---|---|
200 | Response code indicating a successful operation. |
201 | Indicates that the resource is successfully created. |
202 | Indicates that the update is successful. |
400 | Indicates an invalid request. For example, a POST request with out the JSON payload. |
401 | Indicates an authentication-related problem. |
404 | Indicates a resource-not-found error. |
405 | Indicates a method-not-allowed error. |
406 | Indicates an invalid format/Unacceptable data. |
415 | Indicates an invalid content type |
500 | Indicates an internal-server error. |
502 | Indicates a bad gateway error. |
503 | Indicates that the service is unreachable. |
Next Step:
Continue with REST API Examples.