Microsoft ASP.NET WebHooks“在 WebHook 请求中预期正好有一个‘ms-signature’标头字段,但发现为 0". [英] Microsoft ASP.NET WebHooks "Expecting exactly one 'ms-signature' header field in the WebHook request but found 0."

查看:30
本文介绍了Microsoft ASP.NET WebHooks“在 WebHook 请求中预期正好有一个‘ms-signature’标头字段,但发现为 0".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Microsoft ASP.NET WebHooks,我收到错误消息:在 WebHook 请求中期望恰好有一个 'ms-signature' 标头字段,但发现为 0.请确保恰好有一个 'ms-signature' 标头字段"

Using Microsoft ASP.NET WebHooks, I am getting the error message: "Expecting exactly one 'ms-signature' header field in the WebHook request but found 0. Please ensure exactly one 'ms-signature' header field"

$.ajax({
        type: "POST",
        url: "http://localhost:50003/api/webhooks/incoming/custom",
        data: JSON.stringify({
            WebHookUri: "http://localhost:50003/api/webhooks/incoming/custom",
            Secret: "12345678901234567890123456789012",
            Description: "My first WebHook!"
        }),
        contentType: "application/json; charset=utf-8",
        "ms-signature": "3499c60eea227453c779de50fc84d315b9a55a20",
        dataType: "json",
        success: function (data, status) { alert(status); },
        failure: function (errMsg) { alert(errMsg); }
    })
    .done(function (data) {
        alert(data);
    })
.fail(function (jqXHR, textStatus) {

    console.log(jqXHR);
    alert('Something went wrong: ' + textStatus);
})

推荐答案

因此,正如错误消息所解释的那样,它需要一个名为ms-signature"的标头,而不是正文内容.您可以像这样将标头添加到ajax请求:

So, as the error message explained, it is expecting a header called 'ms-signature', as opposed to a body content. You can add headers to the ajax request using the header field like so:

$.ajax({
    type: "POST",
    url: "http://localhost:50003/api/webhooks/incoming/custom",
    headers: { "ms-signature": "3499c60eea227453c779de50fc84d315b9a55a20" }
    ...

希望这会有所帮助.

这篇关于Microsoft ASP.NET WebHooks“在 WebHook 请求中预期正好有一个‘ms-signature’标头字段,但发现为 0".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆