Skip to main content

Web API Testing


Starting with Cycle 2.15, we have improved the way to call web APIs as part of your test automation. We have introduced a new API editor to create and edit API requests. The API requests can then be used in one or more feature files with the new "I call API" step.

Using the API Editor

API Editor]

You can create a new API request using the API Editor by either clicking File -> New -> Cycle API in the menu or by using the Control+K keyboard shortcut.

From within the API Editor you can:

  • Set the request method (GET, POST, PUT, PATCH, DELETE)
  • Set the request URL
    • This can be a static URL, such as
    • It can be a reference to a Cycle variable, such as ${url}
    • It can be a mix of multiple Cycle variables and static text, such as ${protocol}://${url}:${port}/api/v1
  • Supported body types include JSON, XML, and x-www-form-urlencoded.
    • The body can be static text or include one or more Cycle variables, such as { "title": "${title}", "body": "Hello, ${name}" }
  • A convenient table style interface is available for defining any required http headers, query parameters, or x-www-form-urlencoded body.
    • Both the keys and values can be static text, Cycle variables, or a mix of both.
  • If your API requires authentication, you can chose from basic or bearer token and provide the necessary credentials.
    • Best practices for securely handling credentials are to reference Cycle variables rather than hard coding values.
    • More information on injecting secrets and passwords into Cycle can be found in this Knowledge Base Article.
    • Additional examples for securely injecting secretds can be found in this example project.
  • In the Variables Inspector on the right, you can easily see a list of all variables referenced in the API request.
    • This is for ease of use when referencing the API request from a feature. Opening the API editor, one can quickly and conveniently find a list of all variables without having to navigate all parts of the request.
  • Execute the request to validate API information entered prior to running a feature.
  • View output of the API response.

Save your API request by either clicking File -> Save in the menu or using Control+S. When saving your API requests, you can group them in folders just like any other file type in Cycle.

Validating the API from within the editor

To execute the API request from within the editor, use the Save & Test button right of the request URL input. Then view the results to ensure that the response is what was expected and make any other necessary changes.

API Editor

Calling the API from a Feature File

To use the API request from a feature file, use the I call api step with the path within the project to the .api file. A sample scenario is below.

Scenario: Update Data API
Given I assign value "application/json" to unassigned variable "contentType"
And I assign value "My Updated Title" to unassigned variable "title"
When I call api "Requests/update_data.api"
And I verify http response had status code 200
Then I assign http response body to variable "responseBody"
And I echo $responseBody
And I assign value from JSON $responseBody with path "/userId" to variable "userID"
And I echo $userID

If any Cycle variables referenced in the API request are not present when the I call api step is invoked, the step will fail with an error stating Missing required variable with a comma separated list of missing variables. If no URL is defined when the step is invoked, the step will fail with a URL is empty error message. The step will fail if Cycle is unable to complete the request, in such a case as the URL is unreachable. The step will pass when the API provides a response. Additional validations can then be subsequently performed to validate the response's http status, headers, or content of the body.

Sample Project

A video introduction of the API Editor is available.

The sample project from that video can be found here.