REST Request Test Step

Applies to ReadyAPI 3.57, last modified on December 20, 2024

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.

Test step editor overview

Click the image to enlarge it.

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.
You can use the project, test suite or other properties to specify parameter values. For information on request parameter types (QUERY, TEMPLATE, HEADER, and others) and how to specify them in the editor, see REST Parameter Types.
Raw Displays the header and body of the request in a text format.
ReadyAPI populates this tab after you run the test step.
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.
Note: This panel is not available if you specified a JMS endpoint for the request.
JMS Headers Displays the Java Message Service headers.
Note: This panel is available if you specified a JMS endpoint for the request.
JMS Property Displays the Java Message Service properties.
Note: This panel is available if you specified a JMS endpoint for the request.

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.

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 charset header. You can select one of the predefined values or specify a custom value. If it is empty, the utf-8 encoding is used.

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.

Works only when the Follow Redirects property is set to true.
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 & or >) are entitized into (& or >). Set to false if data is already encoded.

Disable Property Expansions

When it is set to true, ReadyAPI does not evaluate property expressions and insert them as they are specified in the request editor.

Multi-Value Delimiter

Sets a delimiter used to separate QUERY parameter values.
For example, if you set the parameter name as sample, its value - as test1,test2 and the delimiter - as ,(comma), the query will be ?sample=test1&sample=test2.

Pretty Print

When this option is set to true, the respone XML panel displays XML data with line breaks and indents. It does not affect the payload data.

Tip: To pretty print contents of the JSON panel of the response, right‑click somewhere within the panel and select Format JSON.
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.

Specified assertions may fail, because there will not be enough data for verifying.
Discard Response

When this option in set to true, ReadyAPI deletes the response data from the memory after the assertion runs. Works only if the test step editor is closed.

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
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.

REST Request test step toolbar

Click the image to enlarge it.

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.
The REST Request does not support specifying a schema from a service definition.
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.

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.

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:

  1. Click API Request on the request editor toolbar.

  2. Select the desired property and modify it according to your needs.

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:

    REST service testing: Loading parameter values from a file

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.

To add a custom header:

  1. Open the Headers panel of the request editor.

  2. Click and specify the desired header and its value.

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.

To add authorization:

  1. Open the Auth panel of the request editor.

  2. Select the desired Authorization profile.

To learn more about authorization, see Authentication.

To verify that the server returns the expected response, use assertions:

  1. Click Add Assertion on the request editor toolbar.

  2. In the Add Assertion dialog, specify the desired assertion.

  3. Set up a new assertion according to your needs and click OK.

See Also

Test Steps
HTTP Request Test Step

Watch the video
 
Highlight search results