About REST Request test step
The REST Request test step sends a REST request of the specified type (GET, POST, PUT and so on), gets a response and validates it with assertions. You can adjust the test step parameters, authorization settings, and so on.
To use the REST Request test step, you need to add a REST service to your project. |
Tip: | Try the new API Connection test step. It is a protocol-agnostic test step that allows you to send REST requests. |
Editing REST Request test step
Each REST request test step is based on a REST request defined in your API. ReadyAPI takes the method, resource and parameters specified for this request. To change these data, you need to link your test step to another REST request. To change the endpoint and parameter values, you can use the test step editor, which is similar to the editor you use to modify requests (see REST Requests). The changes you make to your test step do not affect the base request.
Here is a brief description of available panels in the request editor:
Request |
Displays request parameter information in a table. You can see the parameter’s name, value and type.
|
||
Raw |
Displays the header and body of the request in a text format.
|
||
Outline | Displays the request body as a tree. Works for POST and PUT requests only. You can change elements’ and attributes’ values in-place. Just double-click the cell with the needed value. | ||
Form | Lets you specify parameter values by using various edit controls. | ||
Auth | Use this panel to specify the authorization type (Basic, NTLM, or SPNEGO/Kerberos) and authorization parameters for your request. | ||
Attachments | Allows you to specify the files to be attached to the request. See also SOAP Attachments. | ||
Representations | Displays request representations for the request data. ReadyAPI loads representation information from the web service WADL. | ||
Headers | Use this panel to create and modify custom header fields.
|
||
JMS Headers | Displays the Java Message Service headers.
|
||
JMS Property | Displays the Java Message Service properties.
|
Once you run the test step, the server response is available in the response editor.
Property list
Besides editors and inspectors, you can adjust the test step’s behavior by using its properties in the REST Request Properties and Custom REST Request Test Step Properties panels in the Navigator.
REST Request Properties | View ↓
Name | Description | ||
---|---|---|---|
Bind Address |
The network interface (IP address), through which ReadyAPI will send the request. |
||
Description |
Text description of the test step. |
||
Disable Property Expansions |
When it is set to |
||
Discard Response |
When this option in set to |
||
Dump file |
Specifies the fully qualified name to the file, to which you want to save the server’s response. Leave this property empty not to save the response to a file. |
||
Encoding |
The encoding of the request data in the |
||
Endpoint |
A URL address of the tested web service. |
||
Entitize Properties |
Specifies if special characters should be encoded. HTML symbols (like |
||
Follow Redirects |
Enables handling of redirects. Specify true to allow the request to be sent to a new address. When it is set to false, the request receives the actual response from the server without going to a new address. |
||
Max size |
Specifies the maximum number of response bytes that ReadyAPI shows in the editor to save memory. To show the entire response, specify 0.
|
||
Message Size |
Shows the size of the response in bytes. |
||
Method |
The tested method. |
||
Multi-Value Delimiter |
Sets a delimiter used to separate QUERY parameter values. |
||
Name |
The test step’s name. |
||
Pretty Print |
When this option is set to
|
||
Remove Empty Content |
Remove empty elements from the request. Works for request contents in the XML format. |
||
Resource |
The tested resource to which the test step is sent. |
||
Service |
The tested service name. |
||
SSL Keystore |
The file that stores the private keys used to authorize ReadyAPI when connecting to the server. This works for HTTPS requests only. |
||
Strip whitespaces |
Removes comments and extra whitespaces from elements and attributes. Required by some servers. Works for request contents in the XML format. |
||
Timeout |
The number of milliseconds to wait for a server response. If there is no response during this period, the test step fails. The 0 or absent value means an infinite wait time. |
||
Use GET Method on 302 Redirect |
If set to true, when a server redirects the request with the 302 status code, ReadyAPI sends the GET method.
|
Name | Description | ||
---|---|---|---|
Name |
The test step’s name. |
||
Description |
Text description of the test step. |
||
Message Size |
Shows the size of the response in bytes. |
||
Encoding |
The encoding of the request data in the |
||
Endpoint |
A URL address of the tested web service. |
||
Service |
The tested service name. |
||
Resource |
The tested resource to which the test step is sent. |
||
Method |
The tested method. |
||
Timeout |
The number of milliseconds to wait for a server response. If there is no response during this period, the test step fails. The 0 or absent value means an infinite wait time. |
||
Bind Address |
The network interface (IP address), through which ReadyAPI will send the request. |
||
Follow Redirects |
Enables handling of redirects. Specify true to allow the request to be sent to a new address. When it is set to false, the request receives the actual response from the server without going to a new address. |
||
Use GET Method on 302 Redirect |
If set to true, when a server redirects the request with the 302 status code, ReadyAPI sends the GET method.
|
||
SSL Keystore |
The file that stores the private keys used to authorize ReadyAPI when connecting to the server. This works for HTTPS requests only. |
||
Strip whitespaces |
Removes comments and extra whitespaces from elements and attributes. Required by some servers. Works for request contents in the XML format. |
||
Remove Empty Content |
Remove empty elements from the request. Works for request contents in the XML format. |
||
Entitize Properties |
Specifies if special characters should be encoded. HTML symbols (like |
||
Disable Property Expansions |
When it is set to |
||
Multi-Value Delimiter |
Sets a delimiter used to separate QUERY parameter values. |
||
Pretty Print |
When this option is set to
|
||
Dump file |
Specifies the fully qualified name to the file, to which you want to save the server’s response. Leave this property empty not to save the response to a file. |
||
Max size |
Specifies the maximum number of response bytes that ReadyAPI shows in the editor to save memory. To show the entire response, specify 0.
|
||
Discard Response |
When this option in set to |
Custom REST Request Test Step Properties | View ↓
This tab contains:
-
Properties that correspond to the request parameters.
-
Properties that provide access to the request and response data.
Notes:
-
You can load values of custom properties from a file, or save them to a file. To learn more, see About Properties.
-
Values on the Custom Properties tab are available to other test steps in your project. For instance, you can verify these property values with the Assertion test step, or check them and change the execution flow with the Conditional GoTo test step.
Name | Description |
---|---|
Domain |
Duplicates the Domain property of the REST Request Property tab. Used to get its value by using the property expansion. |
Endpoint |
Duplicates the Endpoint property of the REST Request Property tab. Used to get its value by using the property expansion. |
HarResponse |
The response in the .har format. |
Password |
Duplicates the Password property of the SOAP Request Property tab. Used to get its value by using the property expansion. |
RawRequest |
The body content of the sent request. You can see the same content in the request Raw panel. Property expansions are converted to the expected values. To get the data with unconverted property expansions, use the Request property. |
RawResponse |
Response data with headers. You can see the same content in the Raw panel of the response editor. To get response data without headers, use the Response property. |
Request |
The request body without headers. Property expansions are represented as they are without conversion to expected values. To get the sent request with converted property expansions, use the RawRequest property. |
Response |
The response data without headers. You can see the same content in the response XML panel. To get response data without headers, use the RawResponse property. |
ResponseAsXML |
Response data as an XML DOM document (if possible). |
Username |
Duplicates the Username property of the REST Request Property tab. Used to get its value by using the property expansion. |
Name | Description |
---|---|
Response |
The response data without headers. You can see the same content in the response XML panel. To get response data without headers, use the RawResponse property. |
RawRequest |
The body content of the sent request. You can see the same content in the request Raw panel. Property expansions are converted to the expected values. To get the data with unconverted property expansions, use the Request property. |
Endpoint |
Duplicates the Endpoint property of the REST Request Property tab. Used to get its value by using the property expansion. |
Username |
Duplicates the Username property of the REST Request Property tab. Used to get its value by using the property expansion. |
Request |
The request body without headers. Property expansions are represented as they are without conversion to expected values. To get the sent request with converted property expansions, use the RawRequest property. |
HarResponse |
The response in the .har format. |
Domain |
Duplicates the Domain property of the REST Request Property tab. Used to get its value by using the property expansion. |
ResponseAsXML |
Response data as an XML DOM document (if possible). |
Password |
Duplicates the Password property of the SOAP Request Property tab. Used to get its value by using the property expansion. |
RawResponse |
Response data with headers. You can see the same content in the Raw panel of the response editor. To get response data without headers, use the Response property. |
Test step toolbar
The test step toolbar contains commands that allow you to modify a test step, change the base REST request or customize appearance of the test step editor.
Generate Values
Use the Generate Values button to automatically generate values for parameters in REST request test steps. The value type is deduced from the type of the parameter that is specified in the service definition or, if it's not possible, from the name of the parameter.
To learn more about the feature, see Generate Data Source Automatically.
Verifying response
To add an assertion, use the Add Assertion button on the Request toolbar.
To validate the response content using the data of received responses, click Smart Assertion on the Response editor. To learn more, see Validate response content.
To modify assertions, use the Assertion panel.
The following assertions are available for the REST Request test step:
Name | Description | ||
---|---|---|---|
Property Content: | |||
Contains | Verifies that the response contains the specified string. | ||
Equals | Verifies that the value of a property is equal to the specified value. | ||
Equals (Binary) | Checks whether the binary response is equal to a file. | ||
JsonPath Count | Counts the occurrences of the specified element. | ||
JsonPath Existence Match | Checks whether the specified element exists. | ||
JsonPath Match | Checks whether the specified element matches an expected value. | ||
JsonPath RegEx Match | Checks whether the specified element matches a regular expression. | ||
Message Content Assertion | Verifies that the message contains expected contents. | ||
Not Contains | Verifies that a response does not contain the specified value. | ||
Smart Assertion | Verifies the message content and metadata such as headers and the status code. | ||
XPath Match | Checks whether the result of the specified XPath expression is equal to the specified value. | ||
XQuery Match | Verifies that a result of the specified XQuery expression is equal to the specified value. | ||
Compliance, Status and Standards | |||
HTTP Header Equals | Checks whether the response contains the expected value of an HTTP header. | ||
HTTP Header Exists | Verifies that the response contains the specified HTTP header. | ||
Invalid HTTP Status Codes | Checks whether the HTTP status code is not on the specified list. | ||
JSON Schema Compliance | Verifies that a request and response are compliant with the specified JSON schema. | ||
Schema Compliance | Checks whether the response is compliant with the inferred schema.
|
||
Swagger Compliance Assertion | Verifies that a request and response are compliant with an OpenAPI or Swagger specification. | ||
Valid HTTP Status Codes | Checks whether the HTTP status code is on the specified list. | ||
Script | |||
Script Assertion | Executes a script to perform a custom assertion. | ||
SLA | |||
Response SLA | Checks whether the response was returned within the specified timeout. | ||
JMS Response | |||
JMS Status | Verifies that the JMS request is successful. | ||
JMS Timeout | Checks whether a JMS response returns within a specific time period. | ||
Security | |||
Sensitive Information Exposure | Verifies that the response does not contain any valuable information. |
Logging
While the test step editor is open, brief information on sent requests is listed in the Log tab. If the test step is run as part of a test case, you can see a more detailed log in the Transaction Log panel.
Working with
Below, you can find information on common tasks that you can perform with the REST Request test step.
Change method or resource path
To change a method or the resource path, change the base request:
-
Click API on the request editor toolbar.
-
In the Link REST Request dialog, select the desired request or method and click OK.
Change endpoint
Specify a new endpoint in the test step toolbar. By using a drop-down list, you can select one of the endpoints specified on the Endpoint page of the service editor. The following commands of the list allow you to modify the endpoint list:
-
edit current – changes the selected endpoint.
-
add new endpoint – adds a new endpoint to the list.
-
delete current – removes the selected endpoint from the list.
Another way to modify the endpoint is using the Endpoint property.
Modify request parameters
You can modify request parameter values in the Request panel. These changes will not affect the default values. To restore default values specified in REST Request, click .
To change the parameter name or type, you need to modify the REST request to which this test step refers:
-
Click API Request on the request editor toolbar.
-
Select the desired property and modify it according to your needs.
Load parameter from file
To load the content of any parameter from a file:
-
Add the file to the Attachments panel in the request editor.
-
Get the data by using the property expansion with the following syntax:
file:myFileName.log
:
Use property expansion in properties
To specify values in text boxes and cells in the test step editor, you can use the project, test suite, and other property types. To refer to a property, use the following syntax:
-
${#Project#MyPropertyName}
– Project properties. -
${#TestSuite#MyPropertyName}
– Test suite properties. -
${#Env#MyPropertyName}
– Environment properties.
For more information, see Property Expansion.
Add custom headers
To add a custom header:
-
Open the Headers panel of the request editor.
-
Click and specify the desired header and its value.
Remove the “Content-Length: 0” header
To remove the Content-Length: 0
header from your request, add the -Dsoapui.send.zero.content.length=false
parameter to the vmoptions file located in the <ReadyAPI>/bin directory and restart ReadyAPI.
Specify authorization
Verify response
To verify that the server returns the expected response, use assertions:
-
Click Add Assertion on the request editor toolbar.
-
In the Add Assertion dialog, specify the desired assertion.
-
Set up a new assertion according to your needs and click OK.