Using Eggplant Performance Analyzer with the REST API
Most of the actions that you can perform in the Eggplant Performance Analyzer user interface (UI) can also be automated by using the REST API. This ability could be useful if you run performance tests on a regular basis and want to automate the process of analyzing the data and generating a report. For example, you could use the REST API to integrate Analyzer into a continuous integration (CI) environment.
See all the available REST API methods for Eggplant Performance Analyzer
Starting the REST Server
The REST server is a standalone web server that listens for HTTP requests on a specified port. The path to the REST server is as follows:
<location_where_you_installed_Analyzer>\bin\analyzerRest.exe
For example:
C:\Program Files\eggPlantPerformanceAnalyzer-8.0.0\bin\analyzerRest.exe
To start the REST server, run analyzerRest.exe
from the command line. By default, the REST server listens for requests on port 5000. You can specify a different port number by using the -p
command line option:
analyzerRest.exe -p 8888
Sending requests to the REST server
HTTP requests should be directed to the host and port on which the REST server is listening. In addition, you will need to specify the path of the particular method you wish to execute. For example, to list all the available workspaces and comparisons on the localhost, you would send an HTTP GET request to:
http:PORT/analyzer/api/1.0
For example:
http:/analyzer/api/1.0
All responses received from the REST server will have the MIME type application/json
. For example, the request above would generate a response such as:
{
"comparisons": "http://localhost:5000/analyzer/api/1.0/comparisons",
"workspaces": {
"Workspace 1": "http://localhost:5000/analyzer/api/1.0/Workspace%201"
}
}
You can parse the response to extract the information you need. For example, the response above tells you the URL to go to for information on the Workspace 1 workspace.
Each HTTP response will also have an HTTP response code. A code in the 200 range (e.g., 200
, 201
) indicates that the request was successful. A code in the 400 range (e.g., 400
, 404
) indicates that there was a problem with the HTTP request that was sent.
If a particular method requires you to send a POST request, then any POST data should be sent with the header Content-Type: application/json
, and the POST data should be encoded in JSON format. For example, to import a test run into the analysis database, you would send a request such as:
Content-Length: 99
Content-Type: application/json
Host: localhost:5000
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
{
"path": "C:\\workspaces\\My Workspace\\projects\\My Project\\runs\\My Series\\My Test.1"
}
In most programming languages, you will only need to set the Content-Type
header explicitly; the other headers will usually be set automatically.