使用用于 wiremock.net 的 SDK,我正在尝试在响应中链接 webhook。
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
.WithBodyAsJson(newOrder)
);
答案 0 :(得分:0)
您需要使用方法 WithWebhook(...)
,这在 Wiki 中有描述。
请参阅此示例代码,它将向 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"));