vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

Variable in Array from Response

Open jhuerta opened this issue 2 years ago • 1 comments

Hi,

I know that I can access the response data in this way and use it in other call: # @name people GET {{baseUrl}}/api/People/All @firstPersonId = {{people.response.body.$.[0].id}}

### Get info GET {{baseUrl}}/api/People/{{firstPersonId}}

What I would like to do is to subsitute 0 with a variable, but this approach does not work:

@personIndex= 0

### Get all watches # @name people GET {{baseUrl}}/api/People/All

### Get The First Watch From The List @allPeople= {{people.response.body.$}} @personId= {{allPeople}}[{{personIndex}}].id

This does not work.

And this neither:

@personId= {{people.response.body.$.[personIndex].id}}

Nor this:

@personId= {{people.response.body.$.[{{personIndex}}].id}}

So, how to use a variable inside of the response.body of a request?

Thanks,

Juan

jhuerta avatar Sep 08 '23 06:09 jhuerta

Duplicate of https://github.com/Huachao/vscode-restclient/issues/859. Please go give that a thumbs up.

JtMotoX avatar Mar 11 '24 17:03 JtMotoX