logo
21.2
search
No matching documents found.
list
search
No matching documents found.
logo
Please be aware that there is newer version of documentation available for Webswing. Documentation 24.1

Admin Console REST API

Admin Console uses REST API to communicate with servers. If you want to use any functionality of the Admin Console have a look at the following example that returns information about sessions:

#!/bin/bash
SERVER=http://localhost:8081
ADMIN=http://localhost:8082

#1. login to webswing server (cluster server) to obtain JWT cookies, i.e. POST to https://localhost/webswing-server/login with credentials
curl -k -c cookie.txt -d "username=admin&password=pwd" ${SERVER}/login

#2. GET request to https://localhost/webswing-server/rest/adminConsoleToken, include cookies, waclt cookie is important here
#3. parse access id from the response
ACCESS_ID=$(curl -k -b cookie.txt -s ${SERVER}/rest/adminConsoleToken | jq -r ".accessId")

#4. GET request to https://localhost/webswing-admin-server/rest/login?accessId={accessId}
#5. parse access token from the response
ACCESS_TOKEN=$(curl -k -s ${ADMIN}/rest/login?accessId=${ACCESS_ID} | jq -r ".accessToken")

#6. use the token as Bearer in rest calls
INSTANCE_INFO=$(curl -s -k -H "Authorization: Bearer ${ACCESS_TOKEN}" ${ADMIN}/rest/activeSessionsInfo)
echo $INSTANCE_INFO