When I send a METHOD request to "endpoint" with values:

Sends an HTTP request to a relative endpoint with field values taken from a two-column Gherkin table. Each table row becomes one key-value pair in the request payload, which is serialized as JSON and sent with Content-Type: application/json. The method is uppercase, such as POST or PUT, and the endpoint is appended to the API base URL.

Placeholders in the table values are replaced before sending, and headers set earlier in the scenario are included. Note that all table values are sent as JSON strings; if the endpoint requires typed values such as numbers or booleans, use the with-body variant with a raw JSON doc string, or prepare the payload with the set-request-body table step, which converts numeric and boolean values. HTTP error statuses do not fail the step, so assert on the code afterwards.

Accepted phrasings

When I send a METHOD request to "/endpoint" with values:
When we send a METHOD request to "/endpoint" with values:
When send a METHOD request to "/endpoint" with values:

Examples

When I send a POST request to "/users" with values:
When we send a POST request to "/users" with values:
When I send a PUT request to "/users/1" with values:
When we send a POST request to "/posts" with values:

In a real scenario

Feature: User management API

  Scenario: An editor account is created and then updated
    Given the API base URL is "https://api.example.org"
      And I set header "Authorization" to "Bearer {{token}}"
     When I send a POST request to "/users" with values:
            | name  | Alice Editor      |
            | email | alice@example.org |
            | role  | editor            |
     Then the API response code should be 201
     When I send a PUT request to "/users/1" with values:
            | name | Alice Senior Editor |
     Then the API response code should be 200
      And the API response should contain "Alice Senior Editor"

Related steps

Back to Api Steps