Insomnia: [Feature Request] Allow multiple results for JSONPath in JSON bodies

Created on 23 May 2018  ยท  8Comments  ยท  Source: Kong/insomnia

  • Insomnia Version: 5.16.2
  • Operating System: macOS

Details

I make heavy use of chaining requests with template tags which is very powerful. However, I find it rather restrictive when working with JSON bodies in a POST request.

Use case

I query a REST endpoint which returns an array of elements. In the response preview, I can use a JSONPath such as $.data[*].id to drill down to an array of id strings.

I would like to chain this to another POST request and provide this array as the JSON body. However, when I try to do so, the request fails to render with the following error: Returned more than one result: $.data[*].id

It would be great if JSON arrays could be rendered within JSON bodies.

stale

Most helpful comment

I'd like to see this feature too.
Use case:
Method1 returns an array of objects, each have a "type" and an "id" attribute.
Method2 accepts an array of ids.
I want to use a JSONPath filter on "type" to pass a subset of the ids from Method1's response to Method2.

e.g.
Source data: {"nodes":[{"type" : "T1", "id": 27}, {"type" : "T2", "id": 28}, {"type" : "T1", "id": 29}]}
the following filter
$.nodes[?(@.type=="T1")].id
should return an array of ids
[27, 29]

Please re-open this issue.
Thanks,
Andrew

All 8 comments

๐Ÿ‘‹ Thanks for opening your first issue! If you're reporting a ๐Ÿž bug, please make sure
you include steps to reproduce it. If you're requesting a feature ๐ŸŽ, please provide real
use cases that would benefit. ๐Ÿ‘ช

To help make this a smooth process, please be sure you have first read the
contributing guidelines.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This is a nice feature!

I'd like to see this feature too.
Use case:
Method1 returns an array of objects, each have a "type" and an "id" attribute.
Method2 accepts an array of ids.
I want to use a JSONPath filter on "type" to pass a subset of the ids from Method1's response to Method2.

e.g.
Source data: {"nodes":[{"type" : "T1", "id": 27}, {"type" : "T2", "id": 28}, {"type" : "T1", "id": 29}]}
the following filter
$.nodes[?(@.type=="T1")].id
should return an array of ids
[27, 29]

Please re-open this issue.
Thanks,
Andrew

bump

Hey all, I would like to see this feature as well. Here's my use case.
I have an api whose request body needs a list of id's from an endpoint previously requested.

This is the request body structure.

{
    "items": ["93bef29c-e0c4-4428-bc96-6877b1430ba3"]
}

I get the list of item ids from an /items endpoint.

Can this be reopened? This would be a great feature to have.

I would like this feature as well. The preview JSONPath seemed to show that I would get multiple values, but then I got the Returned more than one result error :cry: when using with Chaining

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fyb3roptik picture Fyb3roptik  ยท  4Comments

chrisvis picture chrisvis  ยท  4Comments

wimdecorte picture wimdecorte  ยท  3Comments

tmaiaroto picture tmaiaroto  ยท  4Comments

isobit picture isobit  ยท  3Comments