Use mocked response data in Webhook body data #583

Closed
opened 2025-12-29 15:27:39 +01:00 by adam · 3 comments
Owner

Originally created by @rmeshksar on GitHub (Mar 9, 2024).

Originally assigned to: @StefH on GitHub.

Hi,
Imagine a mocked API returns response from this template:

{
   "id": "{{Random Type='Guid'}}",
   "name":  "John"
}

This mock API triggers a Webhook call with some delays.

Is it possible in the body data of the WebhookRequest, use the value of id of the response of the original call?

Originally created by @rmeshksar on GitHub (Mar 9, 2024). Originally assigned to: @StefH on GitHub. Hi, Imagine a mocked API returns response from this template: ```json { "id": "{{Random Type='Guid'}}", "name": "John" } ``` This mock API triggers a Webhook call with some delays. Is it possible in the body data of the WebhookRequest, use the value of **id** of the response of the original call?
adam added the question label 2025-12-29 15:27:39 +01:00
adam closed this issue 2025-12-29 15:27:39 +01:00
Author
Owner

@StefH commented on GitHub (Mar 10, 2024):

I think you can use:

request.bodyAsJson.id

See
https://github.com/WireMock-Net/WireMock.Net/wiki/Response-Templating#the-request-model

@StefH commented on GitHub (Mar 10, 2024): I think you can use: request.bodyAsJson.id See https://github.com/WireMock-Net/WireMock.Net/wiki/Response-Templating#the-request-model
Author
Owner

@rmeshksar commented on GitHub (Mar 10, 2024):

Would that be request of the original call or response from the original call?
I am looking to use the response form the original call.

@rmeshksar commented on GitHub (Mar 10, 2024): Would that be request of the original call or response from the original call? I am looking to use the response form the original call.
Author
Owner

@rmeshksar commented on GitHub (Mar 11, 2024):

This worked for me:
{{JsonPath.SelectToken response.bodydata.bodyAsString 'Id'}}

@rmeshksar commented on GitHub (Mar 11, 2024): This worked for me: {{JsonPath.SelectToken response.bodydata.bodyAsString 'Id'}}
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#583