Sends an HTTP request to a relative endpoint with a URL-encoded form body, the format traditional HTML forms submit. The form fields are given as a multi-line doc string with one key=value pair per line. Each key and value is trimmed, URL-encoded, and joined into a single form-encoded payload, and the request is sent with Content-Type: application/x-www-form-urlencoded.
Placeholders in the doc string are replaced before parsing. Lines without an equals sign are ignored, and because the split happens on the first =, values themselves should not contain unencoded equals signs. As with the other send steps, an HTTP error status does not fail the step; assert on the code afterwards. Use this variant for login forms, subscriptions, and other endpoints that expect form submissions rather than JSON.
Accepted phrasings
When I send a METHOD request to "/endpoint" with form data:
When we send a METHOD request to "/endpoint" with form data:
When send a METHOD request to "/endpoint" with form data:
Examples
When I send a POST request to "/login" with form data:
When we send a POST request to "/subscribe" with form data:
When I send a POST request to "/contact" with form data:
When we send a PUT request to "/profile" with form data:
In a real scenario
Feature: Newsletter subscription endpoint
Scenario: A visitor subscribes through the form endpoint
Given the API base URL is "https://www.example.org"
When I send a POST request to "/subscribe" with form data:
"""
email=hello@example.org
list=newsletter
consent=true
"""
Then the API response code should be 200
And the API response should contain "subscribed"
And the API response should not contain "error"