Hello everyone. I am using wiremock to try to make...
# general
p
Hello everyone. I am using wiremock to try to make some callback calls. I have a post serve action that should ideally make another request with a parameter that is included in the request path. This parameter would be included in the URL for the post servver action. I searched for this feature in the documentation that says it is possible, however I am not able to reproduce it. Can anyone clarify me if this is actually possible, or if it depends on versions for example? I am using 2.35. Thank you in advance!
I forgot to say, I am doing this solely by JSON
r
p
Hello @Rob Elliot. Thank you for the quick answer. I forgot to say that the webhook extension is included. It can be called successfully, just not with the resolution of {{request.path.[1]}} (parameter that I want to include in the URL). I am also using response-templating int the transformers part. Should I include anything else?
r
How are you running? Standalone, or embedded? Can you post the code or command you are using to start WireMock & create the stub?
p
I'm running it standalone. This is the command that I am using:
java -cp .\"wiremock-jre8-standalone-2.35.0.jar;wiremock-webhooks-extension-2.35.0.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --extensions org.wiremock.webhooks.Webhooks  --global-response-templating --port 8085 --verbose true
This is the JSON:
Copy code
{
  "mappings": [
    {
      "request": {
        "urlPattern": "/relation-service/param1/finished-relations/(.*)",
        "method": "POST"
      },
      "response": {
        "status": 200,
        "body": "{{request.path.[3]}}",
        "transformers": ["response-template", "body-transformer"]
      },
      "postServeActions": [
        {
          "name": "webhook",
          "parameters": {
            "method": "PUT",
            "url": "<http://localhost:8080/1/app1/application-service/callback/param1/param2/param3/{{request.path.[3]}}>",
            "bodyFileName": "relation-api/originalRequest.json",
            "headers": {
              "Content-Type": "application/json",
            },
            "delay": {
              "type": "fixed",
              "milliseconds": 2000
            },
            "transformers": [
              "response-template"
            ]
          }
        }
      ]
    }
  ]
}
r
And the problem us that
"url": "<http://localhost:8080/1/app1/application-service/callback/param1/param2/param3/{{request.path.[3]}}>"
is not being templated?
p
Exactly. More precisely, The parameter
{{request.path.[3]}}
is not being resolved.
r
Got you - I'll have a look