0

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);
})
Silver Dragon
  • 5,480
  • 6
  • 41
  • 73
mahendramaid
  • 25
  • 10

1 Answers1

0

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" }
    ...

Hope this helps.

Silver Dragon
  • 5,480
  • 6
  • 41
  • 73