Then print API response

Prints the most recent API response to the test output for debugging. The step logs the request method, the full URL, and the response status code, followed by the response body. JSON bodies are pretty-printed with two-space indentation; string bodies are printed as-is.

This step never fails: if no request has been sent yet, it simply prints No API response available and continues. It is a developer aid for inspecting what an endpoint actually returned while you write or debug a feature, and it should be removed before the feature is merged.

Accepted phrasings

Then print API response
And print API response

Examples

Then print API response
And print API response

In a real scenario

Feature: Debug the users endpoint

  Scenario: Inspect the login response while writing the test
    Given the API base URL is "https://api.example.org"
     When I send a POST request to "/api/login" with values:
            | username | editor  |
            | password | secret1 |
     Then the API response code should be 200
      And print API response
      And the API response should contain "token"

Related steps

Back to Api Steps