JSON Response Captures
Source file: examples/json_response_captures.hen
What It Demonstrates
- direct and nested
& body... -> $VARIABLEcaptures - defaulted captures with
:= - dependency reads from earlier requests
- reusing captured values in downstream requests
Key Pattern
GET https://lorem-api.com/api/article/foo
& body.slug -> $ARTICLE_SLUG
& body.author.id -> $AUTHOR_ID
& body.author.email -> $AUTHOR_EMAIL
& body.author.company -> $AUTHOR_COMPANY := unknown
---
> requires: Get Article
GET https://lorem-api.com/api/user/{{ AUTHOR_ID }}
&[Get Article].body.author.email -> $UPSTREAM_AUTHOR_EMAIL
Run It
hen verify ./examples/json_response_captures.hen
hen run ./examples/json_response_captures.hen all --non-interactive
What To Notice
- Captures become ordinary scalar variables for later requests and assertions.
:=gives you a safe fallback when a path may be missing.- Dependency reads let one request pull specific values from an earlier response without recapturing them.
Related reference: JSON selection