hcdocs
hcdocs

Reputation: 1309

How to determine why an Azure Function App is not triggered by a webhook

I have:

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

What doesn't 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

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.

Upvotes: 0

Views: 1009

Answers (1)

Ned-ster
Ned-ster

Reputation: 46

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

Upvotes: 1

Related Questions