PATCH

Command value: requestPATCH

Sends an HTTP PATCH request and asserts on the response status or body.

Fields

FieldJSON propertyDescription
TargettargetURL of the endpoint to call. Variables are supported, for example {{API_URL}}/users.
Assertion Typeassertion_valueStatus equals (status_equals) compares the HTTP status code. Body equals (body_equals) compares the response body. If no type is selected, the response is not checked.
Expected ValuevalueRequired. The expected status code, for example 201, or the expected body. An empty status value is treated as 200.
Request Headerscondition_statementJSON object of headers, for example {"Authorization": "Bearer abc123"}. Sent as written: variables are not resolved here. Invalid JSON fails the step.
Request Bodycondition_resultJSON body sent with the request. Leave empty to send {}.

Usage

  • Runs outside the browser page, so it does not change what is on screen.
  • Use it to seed data before a UI flow or to confirm a backend effect after one.
  • Body equals compares the bodies as JSON (key order does not matter) when both parse as JSON. Otherwise it compares the raw response text.
  • Headers and body are JSON strings sent as written. Variables are resolved in the URL and expected value only.

Example step (JSON)

{
  "command": "requestPATCH",
  "target": "https://api.example.com/items",
  "assertion_value": "status_equals",
  "value": "200",
  "condition_statement": "{\"Authorization\": \"Bearer abc123\"}",
  "condition_result": "{\"name\": \"Item\"}"
}

Playwright equivalent

const res = await page.request.patch('https://api.example.com/items', {
  headers: { Authorization: 'Bearer abc123' },
  data: { name: 'Item' },
});
expect(res.status()).toBe(200);

Common options

  • Make this step optional (Continue on failure): when checked, a failure in this step is recorded and the test continues with the next step.
  • Execute step when JavaScript returns true: not available for request actions.

See conditional steps and variables for details.