question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Response Templating_Method not found error

See original GitHub issue

I am trying to create a wiremock service where if a request comes in matching say an account number, it will respond with a response of say Success and if another account number, it will respond with a response of Bad request. Unfortunately there are json tag elements in the response that will change depending on the request, e.g in my below example RequestId needs to be the same as that of the request, for the downstream system to accept it,else it will be a duplicate transaction , if I hard code the value Request:

{
"RequestId" : "a43d1856",
....
"Accountnumber": "7654322"
}

Response:

{
"RequestId" : "a43d1856",
"ReasonCode" : "Success"
}

I used JsonPathMatcher to match the account number for the request, but I am finding it difficult to figure out how to substitute the dynamic request id from the incoming request to the response.

I tried:

"Response": {
"StatusCode": 200,
"BodyAsJson": {
"RequestId": "{{JsonPath.SelectToken request.body \"$.RequestId\"}}",
"ReasonCode" : "Success"
},
"UseTransformer": true,
"headers": {
"Content-Type": "application/json"
}
}

When I send a request through soapui matching the request, I get response : Method not found

Can you help me with what I am doing wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jthomas2021commented, Feb 15, 2021

Thanks @StefH it worked! Thank you for your help!

0reactions
StefHcommented, Feb 15, 2021

Hello @jthomas2021, is the answer clear to you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wiremock response templating is not working as expected
I'm inserting stubs into the already running remote wiremock server as below as explained under the JSON section in this document.
Read more >
Wiremock using request templating causes parsing error
I'm trying to use Wiremock Request Templating to generate a response from my request body. I am unable to replace the newlines that...
Read more >
Mock API Response Templating
When starting WireMock programmatically, response templating can be enabled by adding ResponseTemplateTransformer as an extension e.g..
Read more >
Template not found 404
If it's a front-end request, and you have a 404 template, then Craft will render your 404 template. If it encounters an error...
Read more >
Returning stubbed HTTP responses to specific requests
HTTP methods currently supported are: GET, POST, PUT, DELETE, HEAD, TRACE, OPTIONS . You can specify ANY if you want the stub mapping...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found