Automation WebHook ASP.NET Core


(markti) #1

I am trying to register my first app using a WebHook but it fails when select the scopes and hit save. I think its because there is probably something wrong with the method signature for my endpoint. I couldn’t find documentation that details out that the WebHook endpoint should look like. Does it post a JSON string using the Request Body? Are there parameters? Does anybody have a link for such documentation? I’m trying to implement using ASP.NET Core (not Node.js) the only example out there seems to be node.js.


(Jim Anderson) #2

I’m guessing that you are seeing the failure because your service is not handing the PING lifecycle sent to it. The documentation for this lifecycle and others can be found here: https://smartthings.developer.samsung.com/docs/guides/smartapps/lifecycles.html

Basically, when you create an app in the workspace, it will POST to your registered URL with request body like this:

{
  "lifecycle": "PING",
  "executionId": "b328f242-c602-4204-8d73-33c48ae180af",
  "locale": "en",
  "version": "1.0.0",
  "pingData": {
    "challenge": "1a904d57-4fab-4b15-a11e-1c4bfe7cb502"
  }
}

Your app would then need to reply to this request with the challenge code:

200 OK
{
  "pingData": {
    "challenge": "1a904d57-4fab-4b15-a11e-1c4bfe7cb502"
  }
}

You should then be able to successfully register your webhook.