api should
Assert last API response status, body, or JSON path
Assertions against the last HTTP response on the Platform: api session.
Forms
| Form | Meaning |
|---|---|
api should status "<code>" | Status code equals |
api should body contain "<fragment>" | Response body contains substring |
api should json path "<path>" exist | gjson path exists |
api should json path "<path>" be "<value>" | gjson path string equals expected |
Examples
Then I api should status "201"
And I api should body contain "book"
And I api should json path "$.id" exist
And I api should json path "$.item" be "book"
And I api should json path "$.id" be "@order-id"Qualifiers
| Qualifier | Role |
|---|---|
status | Expected HTTP status code |
body contain | Substring in response body |
json path | gjson-style path ($.id, …) |
exist | Path must be present |
be | Path string equals expected (resolved) |
Notes
- JSON paths use gjson dialect.
- Expected values in
be/body contain/statusgo through shared resolve (whole-string@slot,$ENV, …).
Related
- api wait (poll until path matches)
- store (
from api json) - Platform: api