API Testing
The "Test API" tool is предназначен for testing REST APIs.
Input File
Input File — a multi-column list in CSV (Comma Separated Values) format. For each line in the input file, an HTTP request to the REST API (HTTP Request) will be executed.
HTTP Request
HTTP Methods
Test API supports the following HTTP methods (HTTP Verbs):
| HTTP Method | Description |
|---|---|
| GET | Requests a representation of a resource. Requests using this method can only retrieve data. |
| POST | Used to submit entities to a specified resource. Often causes a state change or side effects on the server. |
| PUT | Replaces all current representations of the resource with the request data. |
| PATCH | Used for partial modification of a resource. |
| DELETE | Deletes the specified resource. |
Request Resource URL
The URL may use either the HTTP or HTTPS scheme. For example:
https://geo.ipify.org/api/v2/country
Request Body
Test API supports the following request body encoding methods:
| Encoding Method | Description |
|---|---|
| none | Empty (do not send). |
| form-data | multipart/form-data: each value is sent as a data block ("body part"), with a client-defined separator (boundary) separating each part. These keys are provided in the Content-Disposition headers of each part. See RFC2045. |
| x-form-urlencoded | application/x-www-form-urlencoded: values are encoded as key-value pairs separated by &, with = between key and value. Example: apiKey=12345&apiAddress=8.8.8.8. |
| raw | Raw (unencoded) data. The text and RAW data type can be entered in the "Raw" tab. See RAW data types below. |
| RAW Type | Description |
|---|---|
| Text | Plain Text |
| JSON | JSON — a text-based data interchange format derived from JavaScript. |
| HTML | HTML — the markup language for web pages viewed in a browser. |
| XML | XML — extensible markup language. |
Request Parameters
Request parameters are specified in the "Params" tab. You can substitute values from columns of the input file into parameter values using "tags": {%COLUMN1%} — first column, {%COLUMN2%} — second column, etc. Example:
| Parameter | Value |
|---|---|
| apiKey | at_KHpoRtnrtVffSE9oekIYvSvONXLAb |
| apiAddress | {%COLUMN1%} |
In the "Headers" tab, you can define HTTP request headers, for example:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Rate Limits
To reduce server load, APIs often impose limits on the number of client requests per unit of time. Test API includes two settings to help avoid exceeding these limits:
- Requests per second.
0— unlimited. - Requests per minute.
0— unlimited.
Output Data
The results of executed requests will be written to the output file (Output) if one of the following settings is enabled:
- Output HTTP log (Out HTTP Log). Example:
OK,2022-05-09T19:42:43.696+05:00,200,313
OK,2022-05-09T19:42:43.737+05:00,200,290
OK,2022-05-09T19:42:43.758+05:00,200,298
OK,2022-05-09T19:42:43.855+05:00,200,331
- Output source columns (Out Source Columns). Column numbers are listed separated by commas; ranges can also be used:
1-4(from the first to the fourth). Example output of the first column (with "Output HTTP Log" enabled):
20.81.111.85,OK,2022-05-09T19:44:17.505+05:00,200,313
124.108.115.100,OK,2022-05-09T19:44:17.509+05:00,200,298
74.6.231.20,OK,2022-05-09T19:44:17.550+05:00,200,290
64.233.165.139,OK,2022-05-09T19:44:17.576+05:00,200,331
- Result extraction rules are defined for parsing response data. For each rule, you must specify the path and choose the source (
From):JSONorXML.
XML Result Extraction Rule
The path for extracting results from XML is XPath. Example:
//status/node()
//lead_id/node()
JSON Result Extraction Rule
The path for extracting results from JSON is JSON Path, which can be thought of as "XPath for JSON". Opt-In List Manager uses the parser TJSONParser, which implements a subset of the JSON Path specification. Supported child object and property access operators:
- Use
.to access object properties whose names do not contain dots. For example,root.childrefers to thechildproperty of therootobject. - Use
[]to access object properties whose names contain special characters and need quoting, for example:root['child.name'],root["child.name"].
Example:
location.country