Gradito Tunggulcahyo
08/07/2024, 6:56 AMwebhook
I already put the --verbose
on the docker run so it supposed to print all logs
{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "<https://censored.com/callback/eagle>",
"headers": {
"Content-Type": "application/json"
},
"body": "{ \"status_id\": 2, \"query_id\": {{state context='queryIdFdcC123834' property='queryIdFdc'}}, \"user_id\": {{jsonPath originalRequest.body '$.user_id'}}, \"bureau_type\": 2, \"data\": { \"name\": \"ORACLE TAX\"} }"
}
}
but the log only the response of the request
I want to print the request body
and headers
also
how to achieve that?
thankyuu guyss!Lee Turner
08/07/2024, 8:29 AM3.7.0
, successful webhook requests and responses are logged as Sub Events in the request log. You get two events - "type": "WEBHOOK_REQUEST"
and "type": "WEBHOOK_RESPONSE"
https://wiremock.org/docs/webhooks-and-callbacks/#observing-webhook-events
All you need to do is call the admin endpoint to retrieve the requests from the request log
https://wiremock.org/docs/standalone/admin-api-reference/#tag/Requests/operation/getAllRequestsInJournalGradito Tunggulcahyo
08/07/2024, 11:06 AM3.7.0
but somehow it return error like this
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Error 500 java.lang.NoSuchMethodError:
'com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel
com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.from(com.github.tomakehurst.wiremock.http.Request)'
</title>
</head>
<body>
<h2>HTTP ERROR 500 java.lang.NoSuchMethodError:
'com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel
com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.from(com.github.tomakehurst.wiremock.http.Request)'
</h2>
<table>
<tr>
<th>URI:</th>
<td>/v1/reports/clik</td>
</tr>
<tr>
<th>STATUS:</th>
<td>500</td>
</tr>
<tr>
<th>MESSAGE:</th>
<td>java.lang.NoSuchMethodError:
'com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel
com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.from(com.github.tomakehurst.wiremock.http.Request)'
</td>
</tr>
<tr>
<th>SERVLET:</th>
<td>com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet-62d0ac62</td>
</tr>
<tr>
<th>CAUSED BY:</th>
<td>java.lang.NoSuchMethodError:
'com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel
com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.from(com.github.tomakehurst.wiremock.http.Request)'
</td>
</tr>
</table>
<h3>Caused by:</h3>
<pre>java.lang.NoSuchMethodError: 'com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.from(com.github.tomakehurst.wiremock.http.Request)'
at org.wiremock.extensions.state.extensions.RecordStateEventListener.beforeResponseSent(RecordStateEventListener.java:56)
at com.github.tomakehurst.wiremock.extension.ServeEventListener.onEvent(ServeEventListener.java:38)
at com.github.tomakehurst.wiremock.extension.ServeEventListenerUtils.triggerListeners(ServeEventListenerUtils.java:42)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.beforeResponseSent(StubRequestHandler.java:89)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:97)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:165)
at wiremock.jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
at wiremock.org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1665)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:527)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
at wiremock.org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:822)
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:141)
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:563)
at wiremock.org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)
at wiremock.org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)
at wiremock.org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
at wiremock.org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
at wiremock.org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
at wiremock.org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)
at wiremock.org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)
at wiremock.org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)
at wiremock.org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.produce(AdaptiveExecutionStrategy.java:193)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
at java.base/java.lang.Thread.run(Unknown Source)
</pre>
</body>
</html>
Gradito Tunggulcahyo
08/07/2024, 11:06 AM3.6.0
and it working fineLee Turner
08/07/2024, 11:08 AMGradito Tunggulcahyo
08/07/2024, 11:08 AMGradito Tunggulcahyo
08/07/2024, 11:09 AMGradito Tunggulcahyo
08/07/2024, 11:09 AMmockingbird | 2024-08-07 11:05:37.179 Request received:
mockingbird | 192.168.65.1 - POST /v1/reports/clik
mockingbird |
mockingbird | Content-Type: [application/json]
mockingbird | User-Agent: [PostmanRuntime/7.40.0]
mockingbird | Accept: [*/*]
mockingbird | Postman-Token: [f8162510-c4c1-4af2-9ce6-1e5972ed42ca]
mockingbird | Host: [localhost:4301]
mockingbird | Accept-Encoding: [gzip, deflate, br]
mockingbird | Connection: [keep-alive]
mockingbird | Content-Length: [398]
mockingbird | {
mockingbird | "user_id": 12345,
mockingbird | "name": "ORACLE TAX REXI VAGITA",
mockingbird | "gender": "L",
mockingbird | "address": " CEMPAKA PERMAI, DEKAT MASJID",
mockingbird | "sub_district": "CEMPAKA PERMAI",
mockingbird | "district": "GADING CEMPAKA",
mockingbird | "city": "0191",
mockingbird | "postal_code": "38221",
mockingbird | "country": "ID",
mockingbird | "birth_date": "2001-01-16",
mockingbird | "identity_id": "1705141601010002",
mockingbird | "cellphone_number": "082175548936",
mockingbird | "retry": 1
mockingbird | }
mockingbird |
mockingbird |
mockingbird | Matched response definition:
mockingbird | {
mockingbird | "status" : 200,
mockingbird | "body" : "{\n \"data\": {\n \"query_id\": 1234534596\n },\n \"success\": \"true\"\n}\n",
mockingbird | "bodyFileName" : "b2b/user/eagle/clik/response-clik.json",
mockingbird | "headers" : {
mockingbird | "Content-Type" : "application/json"
mockingbird | },
mockingbird | "transformers" : [ "response-template" ]
mockingbird | }
mockingbird |
mockingbird | Response:
mockingbird | HTTP/1.1 200
mockingbird | Content-Type: [application/json]
mockingbird | Matched-Stub-Id: [7987a243-906e-455b-becc-fd000f029203]
Lee Turner
08/07/2024, 11:11 AMLee Turner
08/07/2024, 11:12 AMmockingbird
is a different http mocking solution ?Gradito Tunggulcahyo
08/07/2024, 11:13 AMGradito Tunggulcahyo
08/07/2024, 11:13 AMGradito Tunggulcahyo
08/07/2024, 11:14 AMGradito Tunggulcahyo
08/07/2024, 11:14 AM{
"mappings": [
{
"scenarioName": "C123834 Clik Template",
"request": {
"method": "POST",
"url": "/v1/reports/clik",
"headers": {},
"bodyPatterns": [
{
"matchesJsonPath": "$[?(@.name =~ /ORACLE TAX.*/)]"
}
]
},
"response": {
"status": 200,
"bodyFileName": "b2b/user/eagle/clik/response-clik.json",
"transformers": [
"response-template"
],
"headers": {
"Content-Type": "application/json"
}
},
"serveEventListeners": [
{
"name": "recordState",
"parameters": {
"context": "queryIdClikC123834",
"state": {
"queryId": "{{jsonPath response.body '$.data.query_id'}}"
}
}
},
{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "<https://b2b.requestcatcher.com/callback/eagle>",
"headers": {
"Content-Type": "application/json"
},
"body": "{ \"user_id\": {{jsonPath originalRequest.body '$.user_id' }}, \"query_id\": {{ state context='queryIdClikC123834' property='queryId' }}, \"status_id\": 2, \"bureau_type\": 5, \"data\": { \"bad_credit_status\": 4, \"mothermaidenname\": \"{{ random 'id-ID.Name.firstName' }}\", \"placeofbirth\": \"{{ random 'id-ID.Address.cityName' }}\", \"postalcode\": \"40191\", \"basic_postalcode\": \"40191\", \"employername\": \"PT FINACCEL TEKNOLOGI INDONESIA\", \"employment\": \"004900\", \"fullname\": \"JOHANNES ADRIEL GUSINDRAPUTRA\", \"name\": \"JOHANNES ADRIEL GUSINDRAPUTRA\", \"addressline\": \"JL.SOSIOLOGI 15, 001/007, CIGADUNG, CIBEUNYING KALER, BANDUNG, JAWA BARAT\", \"address\": \"JL.SOSIOLOGI 15, 001/007, CIGADUNG, CIBEUNYING KALER, BANDUNG, JAWA BARAT\", \"contract_valid\": 1, \"bureau_max_pastduedays\": 0, \"bureau_count_late_active_loan\": 0, \"bureau_ever_written_off\": 0, \"bureau_ever_restructured\": 0, \"income_prediction\": 10000000 } }"
}
}
]
}
]
}
Lee Turner
08/07/2024, 11:17 AMorg.wiremock.extensions.state.extensions.RecordStateEventListener.beforeResponseSent
Gradito Tunggulcahyo
08/07/2024, 11:18 AM{
"data": {
"query_id": {{jsonPath request.body '$.user_id'}}{{randomValue length=5 type='NUMERIC'}}
},
"success": "true"
}
here’s the responseLee Turner
08/07/2024, 11:18 AMGradito Tunggulcahyo
08/07/2024, 11:19 AM3.9.1
Lee Turner
08/07/2024, 11:19 AMGradito Tunggulcahyo
08/07/2024, 11:21 AMGradito Tunggulcahyo
08/07/2024, 11:21 AMLee Turner
08/07/2024, 11:21 AMGradito Tunggulcahyo
08/07/2024, 11:24 AMGradito Tunggulcahyo
08/07/2024, 11:30 AMmockingbird | 2024-08-07 11:27:58.335 Admin request received:
mockingbird | 192.168.65.1 - GET /requests?limit=100&since=2016-10-05T12:33:01Z
mockingbird |
mockingbird | User-Agent: [PostmanRuntime/7.40.0]
mockingbird | Accept: [*/*]
mockingbird | Postman-Token: [390a1764-404d-481c-bc32-211fc910993f]
mockingbird | Host: [localhost:4301]
mockingbird | Accept-Encoding: [gzip, deflate, br]
mockingbird | Connection: [keep-alive]
mockingbird |
Lee Turner
08/07/2024, 11:35 AM--no-request-journal
startup parameter it should be enabledGradito Tunggulcahyo
08/07/2024, 11:36 AM--no-request-journal
in startup parameter
but somehow it’s empty….Lee Turner
08/07/2024, 11:38 AMlocalhost:4301
is definitely the server you sent the original request to?Gradito Tunggulcahyo
08/07/2024, 11:39 AMGradito Tunggulcahyo
08/07/2024, 11:42 AMLee Turner
08/07/2024, 11:42 AMGradito Tunggulcahyo
08/07/2024, 11:42 AMGradito Tunggulcahyo
08/07/2024, 11:43 AMGradito Tunggulcahyo
08/07/2024, 11:43 AMGradito Tunggulcahyo
08/07/2024, 11:43 AMGradito Tunggulcahyo
08/07/2024, 11:43 AMpre-request script
Gradito Tunggulcahyo
08/07/2024, 11:43 AMvar urlMock = pm.environment.get("url-mock-local")
pm.sendRequest({
// url: urlMock+ '/__admin/mappings/reset', // Update URL if needed
url: '<http://localhost:4301/__admin/mappings/reset>', // Update URL if needed
method: 'POST'
})
Gradito Tunggulcahyo
08/07/2024, 11:44 AMGradito Tunggulcahyo
08/07/2024, 11:44 AMLee Turner
08/07/2024, 11:44 AMGradito Tunggulcahyo
08/07/2024, 11:46 AM