To Access the data using REST API generate a API token in Applicare and use that token in your request.
Token Generation
Go to menu Applicare Information -> Rest API and click the Generate Token button. The generated token will be displayed in the Token field. It will be displayed only once. So copy the token and keep it safe for future use. Controller saves the token in the encrypted format. Once a new token is generated old token becomes invalid.
REST APIs get the details from the controller
Authentication - API Key Authentication.
Token - One token per controller.
Token Validity - Token expires when a new token is created or if Applicare license expires. After renewing the license the same token will continue to work.
Request content details
Method Type: POST
Content-Type: application/json
REST_API_URL: Controller_Protocol://Controller_IP:Controller_Port/applicare/restapi
Header: X-API-Key: TOKEN_VALUE
REQUEST_BODY: REST API details to fetch
CA_CERTIFICATE_FILE: For SSL Certificate
Response content details
Content-Type: application/json
Success Response
{"status":"success","details":[{"name": "Google","state": "Failed"}]}
Failed Response
{"status":"error","details":[{"error": "Unauthorized. Token is missing or invalid"}]}
status - It displays the response is success or failure
details - Response message (JSON Array)
Curl Syntax
HTTP:
curl -H "X-API-Key: TOKEN_VALUE" -H "Content-Type: application/json" -X POST -d REQUEST_BODY REST_API_URL
HTTPS:
curl --cacert CA_CERTIFICATE_FILE -H "X-API-Key: TOKEN_VALUE" -H "Content-Type: application/json" -X POST -d REQUEST_BODY REST_API_URL
Fields:
CA_CERTIFICATE_FILE: .crt (or) .pem file location
TOKEN_VALUE: Generated Token value from Applicare Console
REQUEST_BODY: REST API details to fetch
REST_API_URL: Controller_Protocol://Controller_IP:Controller_Port/applicare/restapi
Controller_Protocol: Applicare Controller running protocol (http or https)
Controller_IP: Applicare Controller running IP or domain name
Controller_Port: Applicare Controller running Port
For example let us consider the below values
CA_CERTIFICATE_FILE: D:\applicare.pem
TOKEN_VALUE: 123456789
REST_API_URL:
HTTP: http://localhost:8880/applicare/restapi
HTTPS: https://localhost:8443/applicare/restapi
REQUEST_BODY details for different API
1. To get the status of all active synthetic transactions
{"\q\":\"syntheticAllTransactionStatus\"}
Curl Example
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticAllTransactionStatus\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticAllTransactionStatus\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details": [{"name": "Google","state": "Failed"},
{"name": "google","state": "Queued"},{"name": "Json","state":"Success"}]}
name - Synthetic Transaction Name
state - State of the transaction. (Success, Failed or Queued)
2. To get the details of all active synthetic transactions
{\"q\":\"syntheticAllTransactionDetails\"}
Curl Example
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticAllTransactionDetails\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticAllTransactionDetails\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"group": "Default","app": "Applicare",
"name": "Google","node": "ApplicareAdmin","state": "Failed","lastChecked": 1657724700000,
"executionTime": 21040,"message": ""},{"group": "Default","app":"","name": "Json",
"node": "ApplicareAdmin","state": "Success","lastChecked":1657724700000,
"executionTime": 316,"message": ""}]}
group - Group Name
app - Application Name
name - Synthetic Transaction Name
node- In Which Node it executes
state - State of the transaction. (Success, Failed or Queued)
lastChecked - Last execution time
executionTime - Time taken for the transaction. Value in milliseconds
3. To get the transaction status based on transaction names
{\"q\":\"syntheticTransactionStatus\",\"txnname\":\"TXN_NAME1,TXN_NAME2\"}
TXN_NAME1, TXN_NAME2 - Name of synthetic transactions
Curl Example
a. To get the transaction status for single transaction
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"txnname\":\"00001\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"txnname\":\"00001\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details": [{"name": "00001","state": "Failed"}]}
b. To get the transaction status for multiple transactions
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"txnname\":\"00001,00002\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"txnname\":\"00001,00002\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details": [{"name": "00001","state": "Failed"}, {"name": "00002","state":"Success"}]}
4. To get the transaction status based on applications
{\"q\":\"syntheticTransactionStatus\",\"appname\":\"APP_NAME1,APP_NAME2\"}
APP_NAME1, APP_NAME2 - Name of the Application which synthetic transactions was assigned.
Curl Example
a. To get the transaction status for single application
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"appname\":\"TestApp\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"appname\":\"TestApp\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"name":"00004","state":"Queued"}, {"name":"10jmeter","state":"Success"}]}
b. To get the transaction status for multiple applications
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"appname\":\"TestApp,Applicare\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionStatus\",\"appname\":\"TestApp,Applicare\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"name":"00004","state":"Queued"}, {"name":"10jmeter","state":"Success"},{"name":"Error","state":"Failed"}, {"name":"Google","state":"Failed"}]}
5. To get the transaction details based on transaction names
{\"q\":\"syntheticTransactionDetails\",\"txnname\":\"TXN_NAME1,TXN_NAME2\"}
TXN_NAME1, TXN_NAME2 - Name of synthetic transactions
Curl Example
a. To get the transaction details for single transaction
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"txnname\":\"00001\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"txnname\":\"00001\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"group":"Default","app":"","name":"00001","node":"Agent1", "state":"Queued","lastChecked":0,"executionTime":0,"message":""}]}
b. To get the transaction details for multiple transactions
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"txnname\":\"00001,00002\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"txnname\":\"00001,00002\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"group":"Default","app":"","name":"00001","node":"Agent1", "state":"Queued","lastChecked":0,"executionTime":0,"message":""}, {"group":"Default","app":"","name":"00002","node":"ApplicareAdmin","state":"Success", "lastChecked":1657878180000,"executionTime":116720,"message":""}]}
6. To get the transaction details based on applications
{\"q\":\"syntheticTransactionDetails\",\"appname\":\"APP_NAME1,APP_NAME2\"}
APP_NAME1, APP_NAME2 - Name of the Application which synthetic transactions was assigned.
Curl Example
a. To get the transaction for single application
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"appname\":\"TestApp\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"appname\":\"TestApp\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"group":"Default","app":"TestApp","name":"00004", "node":"Agent2","state":"Queued","lastChecked":0,"executionTime":0,"message":""}, {"group":"Default","app":"TestApp","name":"10jmeter","node":"ApplicareAdmin", "state":"Success","lastChecked":1657879080000,"executionTime":1469,"message":""}]}
b. To get the transaction details for multiple applications
HTTP:
curl -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"appname\":\"TestApp,Applicare\"} http://localhost:8880/applicare/restapi
HTTPS:
curl --cacert D:\applicare.pem -H "X-API-Key: 123456789" -H "Content-Type: application/json" -X POST -d {\"q\":\"syntheticTransactionDetails\",\"appname\":\"TestApp,Applicare\"} https://localhost:8443/applicare/restapi
Response
{"status":"success","details":[{"group":"Default","app":"TestApp","name":"00004", "node":"Agent2","state":"Queued","lastChecked":0,"executionTime":0,"message":""}, {"group":"Default","app":"TestApp","name":"10jmeter","node":"ApplicareAdmin", "state":"Success","lastChecked":1657879080000,"executionTime":1469,"message":""}, {"group":"Default","app":"Applicare","name":"Error","node":"ApplicareAdmin", "state":"Failed","lastChecked":1657879020000,"executionTime":24432,"message":""}, {"group":"Default","app":"Applicare","name":"Google","node":"ApplicareAdmin", "state":"Failed","lastChecked":1657879080000,"executionTime":21031,"message":""}]}
Comments
0 comments
Please sign in to leave a comment.