When I send a METHOD request to "endpoint"

Sends an HTTP request to a relative endpoint and stores the response for later assertions. The first parameter is the HTTP method in uppercase, such as GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS. The second parameter is the endpoint path, which is appended to the API base URL set earlier in the scenario.

Any headers set with the header steps are included, and any request body prepared with a set-request-body step is sent along. Placeholders such as {{postId}} in the endpoint are replaced with their configured values. The step never fails on an HTTP error status: a 404 or 500 response is captured normally so you can assert on it with the response-code step afterwards. Only a network-level failure (for example, an unreachable host) fails the step.

Accepted phrasings

When I send a METHOD request to "/endpoint"
When we send a METHOD request to "/endpoint"
When send a METHOD request to "/endpoint"

Examples

When I send a GET request to "/users"
When we send a POST request to "/posts"
When I send a DELETE request to "/posts/1"
When I send a GET request to "/posts/{{postId}}"

In a real scenario

Feature: Health and content endpoints

  Scenario: The API serves the published posts list
    Given the API base URL is "https://api.example.org"
      And I set header "Accept" to "application/json"
     When I send a GET request to "/health"
     Then the API response code should be 200
     When I send a GET request to "/posts?status=published"
     Then the API response code should be 200
      And the response should be valid JSON
      And the API response should contain "title"

Related steps

Back to Api Steps