Open MicHamoNZ opened 6 months ago
Hello,
Here is an example using the name instead,
### Get a random fake user
# @name randomUser
GET https://randomuser.me/api/
Content-Type: @jsonContentType
###
### Guess the nationality based on a name
# @name nationalizeAuto
GET https://api.nationalize.io?name={{randomUser.response.body.$.results[0].name.first}}
Content-Type: @jsonContentType
###
Sending the first request:
and then the second one:
Anyway, I suspect that in your case:
I have tried a number of ways to extract the gender using a Request Variable assignment. for use in my next request however, as soon as I uncomment this code I get a 'Bad Request' error and hovering over the line of text I get various errors.
@gender = {{randomUser.response.body.$.gender}} @gender = {{randomUser.response.body.result[0].gender}}
It's results
, plural, also you need to use the $
to fetch the relevant json field:
{{randomUser.response.body.$.results[0].gender}}
Hope this can help, merry xmas! π€ΆβοΈππ
Hi, just getting started with this extension and finding it very useful. Thanks
I am struggling with extracting parts of my response to a Request Variable as I don't seem to be able to get the JSONPath / XPath correct.
@name randomUser
GET https://randomuser.me/api/ Content-Type: application/json
May named request '@randomUser', returns the following response Body. { "results": [ { "gender": "female", "name": { "title": "Miss", "first": "Evie", "last": "Walker" }, "email": "evie.walker@example.com", "dob": { "date": "1966-01-22T05:24:59.554Z", "age": 57 }, "phone": "(395)-108-2591", "cell": "(939)-256-1145" } ], "info": { "seed": "04e5308488436fe0", "results": 1, "page": 1, "version": "1.4" } }
I have tried a number of ways to extract the gender using a Request Variable assignment. for use in my next request however, as soon as I uncomment this code I get a 'Bad Request' error and hovering over the line of text I get various errors.
@gender = {{randomUser.response.body.$.gender}} @gender = {{randomUser.response.body.result[0].gender}}
Are you able to help