Request body with json array

1,478 views
Skip to first unread message

Ganesan Natarajan

unread,
Oct 19, 2017, 5:17:03 PM10/19/17
to wiremock-user
Hi,

I am looking for a way to mock a post request with body like below
[
 {"name": "Foo"},
 {"name":"Bar"}
]

And I need to send a response back with another json array with some data for the requested "names"
My response should be like

[
 {"name": "Foo", "Address": "123 ABC Parkway"}, 
 {"name":"Bar", "Address": "456 DEF Parkway"}
]

You get the idea, right? Also, the no. of elements in the request's body json array can grow and correspondingly, the json elements in the response array should dynamically be generated matching the no. of elements in the request array.

Any idea on how this can be achieved?

Regards

Tom Akehurst

unread,
Oct 20, 2017, 8:06:05 AM10/20/17
to wiremock-user
Matching a JSON request body is easy enough. See http://wiremock.org/docs/request-matching

Where do you want the data to injected into the response to come from?

Seweryn Walendzik

unread,
Jun 7, 2018, 10:10:10 AM6/7/18
to wiremock-user
did you solve your problem ?
Reply all
Reply to author
Forward
0 new messages