Wiremock.net with web hooks

Viewed 215

Using the SDK for wiremock.net I'm trying to link up a webhook on the response.

  .RespondWith(Response.Create()
      .WithStatusCode(200)
      .WithHeader("Content-Type", "application/json")
      .WithBodyAsJson(newOrder)
  );
1 Answers

You need to use the method WithWebhook(...), this is described at the Wiki.

See this example code which will send a post-request to a webhook.

var server = WireMockServer.Start();
server.Given(Request.Create().UsingPost())
    .WithWebhook(new Webhook
    {
        Request = new WebhookRequest
        {
            Url = "https://any-endpoint.com",
            Method = "post",
            BodyData = new BodyData
            {
                BodyAsString = "OK !",
                DetectedBodyType = BodyType.String
            }
        }
    })
    .RespondWith(Response.Create().WithBody("a-response"));
Related