Automation WebHook ASP.NET Core

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.

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.

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.

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.

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.

1 Like

A bit late on the topic but decided to make a go at creating a ST WebHook SDK for .NET Core. The premise is that it uses DI to inject handlers for the various request types. Using DI allows it to be injected into any .NET Core app including ASP.NET Core and Azure Functions.

The Repo is here. Currently just a first pass with 2 samples, one for ASP.Net Core Web API and one for an Azure Functions HttpTrigger. Both samples allow for a very basic WebHook based SmartApp that uses a single-page configuration to display a single section with a boolean toggle.

I will expand on the README and tune the functionality once I port my favorite groovy based SmartApp using this SDK. Of course I am also happy to take on contributors. Please use the issues feature in the repo to report any issues.

1 Like

Looks cool. I’ll pull it down and take a peak!

1 Like