Skip to content

Chaining the capture from the output of running a Hurl file as input for another Hurl file #3455

Answered by jcamiel
OctavianHome asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @OctavianHome

What can be done with Hurl current version is using --json : this way we have a structured output of the response and we can extract "easily" captured value.

With this file:

GET https://jsonplaceholder.typicode.com/todos/1
HTTP 200
[Captures]
userId: jsonpath "$['userId']"
id: jsonpath "$['id']"

We can run it with --json:

$ hurl --json file1.hurl --output file1.json
$ # Get the userId value and the Id
$ USER_ID=$(cat file1.json | jq '.entries[0].captures[0].value')
$ ID=$(cat file1.json | jq '.entries[0].captures[1].value')
$ hurl --variable "userId=${USER_ID}" --variable "id=${ID}" file2.hurl

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@OctavianHome
Comment options

Answer selected by jcamiel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants