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

vinod p

03/05/2024, 3:54 PM
Hi all, i am trying to use wiremock for mocking responses and callback .
Copy code
{
    "request": {
        "method": "POST",
        "urlPattern": {{url_match_pattern}}
    },
    "response": {
        "status": 200,
        "jsonBody": {
            "request_id": {{request_id_one}}
        },
        "headers": {
            "Content-Type": "application/json"
        }
    },
    "serveEventListeners": [
        {
            "name": "l3vpn",
            "parameters": {
                "method": "POST",
                "url": "{{jsonPath originalRequest.query '$.callback_url'}}/{{request_id_one_str}}",
                "delay": {
                    "type": "fixed",
                    "milliseconds": 5000
                },
                "headers": {
                    "Content-Type": "application/json"
                },
                "jsonBody": {
                    "inprocess": "in process method"
                }
            }
        }
     ]
 }
The callback is received on the callback_url passed along in the headers of request. But the content of callback is empty. i expect following response in the callback body:
Copy code
"inprocess": "in process method"
t

Tom

03/05/2024, 4:00 PM
If the callback URL is a normal query parameter then JSONPath extraction won’t work. Try something like:
Copy code
url": "{{originalRequest.query.callback_url.0'}}"
v

vinod p

03/05/2024, 4:01 PM
thanks. I think my question is not clear enough. My problem is that the body recevied on the callback_url is empty.
t

Tom

03/05/2024, 4:02 PM
Not sure I understand what you mean - can you elaborate?
v

vinod p

03/05/2024, 4:03 PM
i receive POST on the callback_url. but the received body on the callback_url is empty.
t

Tom

03/05/2024, 4:07 PM
What do you mean “body on the callback_url”?
The HTTP request body sent to your target endpoint?
Ah, I see the problem -
jsonBody
isn’t supported for webhooks
Use
body
instead, which needs to be a String
v

vinod p

03/05/2024, 4:14 PM
ok.. thanks. does it mean that i cannot use jsonbody in webhooks?
t

Tom

03/05/2024, 4:14 PM
Yes, that's correct
v

vinod p

03/05/2024, 4:18 PM
ok. Thanks
I have another quey. but it is a bit of explanation required for it. here it is: i want to return a random request id in response and use the same request id in callback body. Is it possible ?
i am putting this on the main chat window .. thanks
13 Views