0
votes

I have:

  • An JavaScript Azure Function in an HTTP webhook configuration; the Function provides a URL; the Function performs an action
  • A webhook configured in the software I hope to receive notifications from
  • An Azure Logic App with an HTTP/webhook step that provides a URL for the webhook notification to go to

My goal is that the Azure Function's URL receives notifications from the software's webhook and performs an action. The Azure Logic App is for testing only.

What works

  • When the the Azure Logic App's URL is used in the software's webhook configuration, the desired action is performed. All works as expected.
  • The Azure Logic App's logging shows the JSON output from the incoming webhook. I expect (but believe this may be where I am going wrong) that this is the JSON the webhook is sending to the Azure Logic App's URL. When this JSON is used in the Azure Function UI's "Test" tab > "Request body" field, the desired action is performed. All works as expected.
  • When the Azure Function's URL and the JSON is in a Postman request, the desired action is performed. All works as expected.

What doesn't work

  • When the Azure Function's URL is used in the software's webhook configuration, no action is performed. This is of course my goal. From everything I have read, I understand that this URL as a webhook endpoint should work.

Azure Function's URL

This is from Get function URL > default (Function key).

https://<app_name>.azurewebsites.net/api/content?code=<api_key>

Other Azure Function config settings

  • Allowed HTTP methods: GET, POST
  • Authorization level: Function

The JSON I believe to be coming over the webhook

{
  "headers": {
    "Expect": "100-continue",
    "Host": "redacted",
    "X-Telligent-Webhook-Sender": "redacted",
    "Content-Length": "16908",
    "Content-Type": "application/json; charset=utf-8"
  },
  "body": {
    "events": [{
      "TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
      "DateOccurred": "2018-12-17T22:55:37.7846546Z",
      "EventData": {
        "ActorUserId": 9999,
        "ContentId": "redacted",
        "ContentTypeId": "redacted",
        "ForumReplyId": 9999,
        "ForumThreadId": 9999,
        "ForumId": 9999
      }
    }]
  }
}

I also tried with the following test code for the same results. It aligns more closely with the sample payload data provided by the software company:

What I tried

{
  "events": [{
    "TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
    "DateOccurred": "2018-12-17T22:55:37.7846546Z",
    "EventData": {
      "ActorUserId": 9999,
      "ContentId": "redacted",
      "ContentTypeId": "redacted",
      "ForumReplyId": 9999,
      "ForumThreadId": 9999,
      "ForumId": 9999
    }
  }]
}

Sample payload data

{
  "events": [
    {
      "TypeId": "407ad3bc-8269-493e-ac56-9127656527df",
      "DateOccurred": "2015-12-04T16:31:55.5383926Z",
      "EventData": {
        "ActorUserId": 2100,
        "ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
      }
    },
    {
      "TypeId": "3b75c5b9-4705-4a97-93f5-a4941dc69bc9",
      "DateOccurred": "2015-12-04T16:48:03.7343926Z",
      "EventData": {
        "ActorUserId": 2100,
        "ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
      }
    }
  ]
}

I do not know how to determine why the Azure Function is not triggered by the webhook. The software's API documentation does not seem to provide a way to look at the JSON being sent over the webhook, although in my inexperience I may be wrong.

Is there a mechanism within Azure, or Postman, or another tool that lets me see what JSON is being sent over the webhook? Or perhaps is there another approach to determining the cause of the issue?

Thank you for any help.

1
Could you try a simple function app which just logs the sent data and try?PramodValavala-MSFT
you can use a tool like Hookbin (google it) to capture the JSON on the request... I know this is 2 years old, but beware.bytejunkie

1 Answers

1
votes

This is how I got the JSON file from Azure alerts.

  1. Install Ruby on the server
  2. Install Sinatra with following command gem install sinatra
  3. Create file webhook.rb and paste code bellow
require 'sinatra'

set :port, 80
set :bind, '0.0.0.0'

post '/event' do
  status 204 #successful request with no body content

  request.body.rewind
  request_payload = JSON.parse(request.body.read)

  #append the payload to a file
  File.open("events.txt", "a") do |f|
    f.puts(request_payload)
  end
end
  1. Run the web service with command ruby webhook.rb
  2. JSON fill be written to file events.txt