Gradito Tunggulcahyo
05/15/2024, 9:56 AMresponse
that generated by wiremock
can i access the response
json key?
this is the response json
that i stored in __files
folder
{
"data": {
"query_id": {{jsonPath request.body '$.user_id'}}{{randomValue length=10 type='NUMERIC'}}
},
"message": "",
"status": "OK"
}
i want the query_id
used in the callback
can i store that query_id
into a variable? and how to achieve that?Lee Turner
05/15/2024, 10:10 AMGradito Tunggulcahyo
05/15/2024, 10:14 AMGradito Tunggulcahyo
05/15/2024, 10:14 AMGradito Tunggulcahyo
05/15/2024, 10:14 AMGradito Tunggulcahyo
05/16/2024, 7:32 AM{
"name": "recordState",
"parameters": {
"context": "{{jsonPath response.body '$.data.query_id'}}",
"state": {
"queryId": "{{jsonPath response.body '$.data.query_id'}}"
}
}
}
but how to retrieve it?
i tried like this in my callback
{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "<https://test.requestcatcher.com/callback/eagle>",
"headers": {
"Content-Type": "application/json"
},
"body": "{\"status_id\":\"{{#if (jsonPath response.body \'$.data.query_id\')}}{{state context=(jsonPath response.body \'$.data.query_id\') property=\'queryId\'}}{{else}}defaultValue{{/if}}\"}"
}
}
but it always return the defaultValue
am i missed something?
thankyouuGradito Tunggulcahyo
05/16/2024, 9:36 AM{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "<https://dadit.requestcatcher.com/callback/eagle>",
"headers": {
"Content-Type": "application/json"
},
"body": "\"status_id\":{{state context=\"jsonPath response.body '$.data.query_id'\" property='queryId'}}"
}
}
and the log is like this
mockingbird | Response:
mockingbird | HTTP/1.1 200
mockingbird | Content-Type: [application/json]
mockingbird | Matched-Stub-Id: [90811e28-e7dd-4da3-ae80-671024f6b8ed]
mockingbird |
mockingbird | 2024-05-16 09:34:47.200 Context '17157633961669999': created
mockingbird | 2024-05-16 09:34:47.201 Context '17157633961669999': property 'queryId' updated
mockingbird | 2024-05-16 09:34:47.203 Context 'jsonPath response.body '$.data.query_id'': property 'queryId' not found, using `null`
mockingbird | 2024-05-16 09:34:48.249 Webhook POST request to <https://test.requestcatcher.com/callback/eagle> returned status 200
mockingbird |
mockingbird | request caught
Gradito Tunggulcahyo
05/16/2024, 9:36 AMqueryId
still emptyGradito Tunggulcahyo
05/16/2024, 10:01 AMLee Turner
05/16/2024, 10:01 AMGradito Tunggulcahyo
05/16/2024, 10:34 AMcontext
shouldnt be so complicated, just make a simpler one
"serveEventListeners": [
{
"name": "recordState",
"parameters": {
"context": "queryId",
"state": {
"queryId": "{{jsonPath response.body '$.data.query_id'}}"
}
}
},
{
"name": "webhook",
"parameters": {
"method": "POST",
"url": "<https://test.requestcatcher.com/callback/eagle>",
"headers": {
"Content-Type": "application/json"
},
"body": "\"status_id\":{{state context='queryId' property='queryId'}}"
}
}
]
i think the readme.md
of that repo should be simplify for the context
itself hahahaha
so not make anyone confuse for how to use it~
at least the documentation can be related on each sectionLee Turner
05/16/2024, 11:59 AM