AAI provides a robust API and a Swagger page that provides a number of API endpoints and examples of how to use them.
The REST API Swagger page can be reached using the URL below:
http://<hostname>:<port>/aai/devPreview
However in order to use any of them, you must first authenticate, which you can do via the API call below:
Once you authenticate you can make other API calls via the swagger page without having to immediately authenticate again.
This is helpful when using the swagger page, however if you wanted to make API calls in a script you would still need a way to authenticate on each API call.
How can a user authenticate when using a script?
AAI 24.1 and later
For example if you wanted to use a curl script to make an API call, you can use the example below to first authenticate and get a cookie.
In the example below update your username, password, and domain(default is JAWS),
///Login to get cookie
curl -i -c cookies.txt -X POST http://<hostname>:8080/aai/api/authentication/login \
-H "Content-Type: application/json" \
-d '{"user":"userName","password":"password","domain":"DomainName"}'
The cookie will get stored in cookies.txt
Then reference that file in api calls after that.
curl -i -b cookies.txt http://<hostname>:8080/aai/api/some_endpoint
For example to get all jobs:
curl -i -b cookies.txt http://<hostname>:8080/aai/api/jobs?fetch=default&maxSize=100&startIndex=0