https://linen.dev logo
#general
Title
# general
r

Rakesh Priyatham

03/30/2023, 10:49 AM
Hi, I'm trying to use #eq with request.body field inside the response file and it's not working. I'm getting an error.
{
"id": "12345",
"country":  "{{jsonPath request.body '$.country'}}",
"capital": "{{#eq (jsonPath request.body '$.country') 'France'}}}Paris{{else}}Sorry{{/eq}}"
}
t

Tom

03/30/2023, 10:52 AM
Hi @Rakesh Priyatham, what’s the error you’re seeing and for what request body JSON?
r

Rakesh Priyatham

03/30/2023, 10:54 AM
request body:
{
"country":  "France"
}
Error:
<http://wiremock.com|wiremock.com>.google.common.util.concurrent.UncheckedExecutionException: <http://wiremock.com|wiremock.com>.github.jknack.handlebars.HandlebarsException: inline@2cae7ad2:2:74: found: &apos;}}}&apos;, expected: &apos;}}&apos;
&quot;currencyCode&quot;: &quot;{{#eq (jsonPath request.body &apos;$.country&apos;) &apos;France&apos;}}}Paris{{else}}Sorry{{/eq}}&quot;,
^
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$Segment.get(LocalCache.java:2055)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache.get(LocalCache.java:3966)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4863)
at com.github.tomakehurst.wiremock.extension.responsetemplating.TemplateEngine.getTemplate(TemplateEngine.java:96)
at com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer.transform(ResponseTemplateTransformer.java:119)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.applyTransformations(InMemoryStubMappings.java:102)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:84)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:229)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:59)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:75)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:142)
at wiremock.javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1656)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:552)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:772)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.Server.handle(Server.java:516)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at <http://wiremock.org.eclipse.jetty.io|wiremock.org.eclipse.jetty.io>.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at <http://wiremock.org.eclipse.jetty.io|wiremock.org.eclipse.jetty.io>.FillInterest.fillable(FillInterest.java:105)
at <http://wiremock.org.eclipse.jetty.io|wiremock.org.eclipse.jetty.io>.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
at <http://wiremock.org|wiremock.org>.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: <http://wiremock.com|wiremock.com>.github.jknack.handlebars.HandlebarsException: inline@2cae7ad2:2:74: found: &apos;}}}&apos;, expected: &apos;}}&apos;
&quot;currencyCode&quot;: &quot;{{#eq (jsonPath request.body &apos;$.country&apos;) &apos;France&apos;}}}Paris{{else}}Sorry{{/eq}}&quot;,
^
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsErrorReporter.syntaxError(HbsErrorReporter.java:93)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.antlr.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.antlr.Parser.notifyErrorListeners(Parser.java:544)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsErrorStrategy.reportInputMismatch(HbsErrorStrategy.java:186)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.antlr.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsParser.block(HbsParser.java:603)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsParser.statement(HbsParser.java:326)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsParser.body(HbsParser.java:231)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsParser.template(HbsParser.java:174)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.internal.HbsParserFactory$1.parse(HbsParserFactory.java:88)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.cache.NullTemplateCache.get(NullTemplateCache.java:54)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.Handlebars.compile(Handlebars.java:575)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.Handlebars.compileInline(Handlebars.java:535)
at <http://wiremock.com|wiremock.com>.github.jknack.handlebars.Handlebars.compileInline(Handlebars.java:515)
at com.github.tomakehurst.wiremock.extension.responsetemplating.HandlebarsOptimizedTemplate.uncheckedCompileTemplate(HandlebarsOptimizedTemplate.java:56)
at com.github.tomakehurst.wiremock.extension.responsetemplating.HandlebarsOptimizedTemplate.<init>(HandlebarsOptimizedTemplate.java:51)
at com.github.tomakehurst.wiremock.extension.responsetemplating.TemplateEngine.lambda$getTemplate$0(TemplateEngine.java:96)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4868)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3533)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2282)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2159)
at <http://wiremock.com|wiremock.com>.google.common.cache.LocalCache$Segment.get(LocalCache.java:2049)
... 35 more
I want to understand how to use the jsonPath request.body along with #eq inside the response file
I'm not sure if my syntax is correct or not
5 Views