SmartThings Community

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.


Python 3 & Flask Webhook Automation
(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.


(markti) #3

Thanks for the response. Is there an Open API specification for the web API interface? That would be most helpful as I could generate a client in .NET Core.


(Jim Anderson) #4

If you visit https://smartthings.developer.samsung.com/develop/api-ref/st-api.html, you’ll see a link towards the top of the document to download the OpenAPI specification.


(Eric Rodewald) #5

Is your project OSS? I have a long history with C# and would love to see an automation written with it. If I can help with automation or API related questions, just ping me.