{
"request": {
"method": "POST",
"urlPathPattern": "/orders",
"headers": {
"Content-Type": {
"equalTo": "application/xml"
},
"Host": {
"contains": "wiremock"
}
}
},
"response": {
"status": 201,
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<OrderResponse>\n<Order>\n<id>{{parameters.orderId}}</id>\n<Quantity>{{parameters.quantity}}</Quantity>\n</Order>\n<OrderStatus>RECEIVED</OrderStatus>\n</OrderResponse>",
"headers": {
"Content-Type": "application/xml"
},
"transformers": ["response-template"],
"transformerParameters": {
"orderId": "{{randomValue type='UUID'}}",
"quantity": "${jsonPath request.body '$.Order.Quantity'}"
}
},
"serveEventListeners": [
{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "https://anywebhook.com/update",
"body": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<OrderResponse>\n<Order>\n<id>{{parameters.orderId}}</id>\n<Quantity>{{parameters.quantity}}</Quantity>\n</Order>\n<OrderStatus>COMPLETE</OrderStatus>\n</OrderResponse>"
}
}
]
}
Hi All
Can you please guide what am I doing WRONG in transformerParameters to generate unique orderid using uuid. Also I want to use same order id in both response and web-hook call.
Also the quantity that I received from request I want to place it in both response body and web hook body
t
Tom
04/02/2024, 7:03 PM
Unfortunately you can’t use templating in transformer parameters.
To achieve what you’re attempting the best approach at the moment is to load the state plugin and set the ID as a state key, then read it in the webhook body template.