How to send API requests to AppVerify using cURL?

This article will walk you through the format and syntax used when making AppVerify API requests with cURL. cURL is a lightweight, command-line tool for making HTTP/HTTPS requests without a web browser. cURL lets you try out various API requests in a command-line interface such as the command prompt in Windows or Terminal in macOS.

Note: You can use any other API tools such as Postman to sends the API commands to AppVerify Manager.

Using cURL in Windows

cURL isn't installed in Windows by default. You can download and install cURL as follows.

  1. In Windows machine, create a new folder called curl in your C: drive. C:\curl

  2. Go to cURL's Download page and download the version that is compatible with your Windows version. 

  3. Unzip the downloaded file and move the curl.exe file to your C:\curl folder.

Now, you can use the Windows command prompt to run the cURL commands. Go to C:\curl folder, type cmd in the search box, and press Enter.

AppVerify API requests using cURL

Generate a Token

Authenticate the user with the Manager, and obtain a token.

Request:

XML: 

Curl -X POST -d "username=[username]&password=[password]" http://IP Address:port number/api/generatetoken

JSON:

Curl -X POST -d "username=[username]&password=[password]" http://IP Address:port number/api/generatetoken [-H "Accept: application/json"] 

Example: 

XML: 

Curl -X POST -d "username=admin&password=admin" http://172.169.12.41:8888/api/generatetoken

JSON:

Curl -X POST -d "username=admin&password=admin" http://172.169.12.41:8888/api/generatetoken -H "Accept: application/json"  

Response:

[Token Value] i.e. 6d83469eea9ffc77431c0013aeb944170a1699513f39

Generate a Test run

This takes the Test plan ID as input and generates a Test run based on an existing Test plan. 

Request: 

XML:

Curl -X POST http://IP Address:port number/api/createtpr -H "Authorization: Token [Token Value]" -d "tp_id=[Test Plan ID]"

JSON:

Curl -X POST http://IP Address:port number/api/createtpr -H "Authorization: Token [Token Value]" -d "tp_id=[Test Plan ID]" [-H "Accept: application/json"]
Example: 

XML: 

Curl -X POST http://172.169.12.41:7777/api/createtpr -H "Authorization: Token 6d83469eea9ffc77431c0013aeb944170a1699513f39" -d "tp_id=ATP-47086"

JSON:

Curl -X POST http://172.169.12.41:7777/api/createtpr -H "Authorization: Token 6d83469eea9ffc77431c0013aeb944170a1699513f39" -d "tp_id=ATP-47086" -H "Accept: application/json"

Response:

"Test run was created successfully."

A Test run will be generated for the Test plan (i.e. ATP-47086). 

Tip: You can find the desired Test plan ID next to the Test plan name in the "Test Plans" section.

Play a Test run

This takes the Test plan ID and Test run number as inputs. Then it finds the available rTesters and have them start playing the processes.

Request: 

XML:
curl -X POST http://IP Address:port number/api/playtpr -H "Authorization: Token [Token Value]" -d "tp_id=[Test Plan ID]&tpr_id=[Test Plan Run #]"

JSON:

curl -X POST http://IP Address:port number/api/playtpr -H "Authorization: Token [Token Value]" -d "tp_id=[Test Plan ID]&tpr_id=[Test Plan Run #]" [-H "Accept: application/json"]
Example: 
XML:
curl -X POST http://172.169.12.41:8888/api/playtpr -H "Authorization: Token 6d83469eea9ffc77431c0013aeb944170a1699513f39" -d "tp_id=ATP-47086&tpr_id=2"

JOSN:

curl -X POST http://172.169.12.41:8888/api/playtpr -H "Authorization: Token 6d83469eea9ffc77431c0013aeb944170a1699513f39" -d "tp_id=ATP-47086&tpr_id=2" -H "Accept: application/json"

Response:

"Test run was started to play."

The Test run (i.e. #2) of Test plan (i.e. ATP-47086) will start playing.

Generate and play a Test run 

This takes the Test plan ID as input and generates a Test run based on an existing Test plan. Then, it finds the available rTesters and have them start playing the processes.

Request: 

XML:

Curl -X POST http://IP Address:port number/api/createandplaytpr -H "Authorization: Token [Token Value]" -d "tp_id=[Test Plan ID]"

JSON:

Curl -X POST http://IP Address:port number/api/createandplaytpr -H "Authorization: Token [Token Value]" -d "tp_id=[Test Plan ID]" [-H "Accept: application/json"]
Example: 

XML:

Curl -X POST http://172.169.12.41:888/api/createandplaytpr -H "Authorization: Token 6d83469eea9ffc77431c0013aeb944170a1699513f39" -d "tp_id=ATP-65621"

JSON:

Curl -X POST http://172.169.12.41:8888/api/createandplaytpr -H "Authorization: Token 6d83469eea9ffc77431c0013aeb944170a1699513f39" -d "tp_id=ATP-65621" -H "Accept: application/json"

Response:

"Test run was created and started to play."

The Test run of Test plan (i.e. ATP-65621will start playing. 

Using cURL in macOS

cURL is installed by default on macOS. Just open the computer's terminal and try to send the API commands to AppVerify Manager using the instructions given above.