TargetUnreachableError - new REST API - webhookSmartApp

Hello,

I am trying to register my Smart App using :

       curl -X POST https://api.smartthings.com/v1/apps \
        -H "Authorization: Bearer <my token>" \
        -H "Content-Type: application/json; charset=utf-8" \
       -d $'{"appName": "<myAppName>", "displayName": "
    <myAppDisplayName>", "description": "<my-
      Description>", "appType": "WEBHOOK_SMART_APP", 
    "webhookSmartApp": {"targetUrl": 
    "https://l103.111.23.34:8443/smartthings"}}'

My server is running correctly in this time ,it is written in node but I get a
error response:

       {
      "requestId": "dd29a5f9-7d87-7d54-8095-f6ced47bdfb0",
      "error": {
       "code": "ConstraintViolationError",
       "message": "The request is malformed.",
       "details": [
           {
                "code": "TargetUnreachableError",
                "target": "https://103.111.23.34:8443/smartthings",
                 "message": "Unable to communicate with target.",
                 "details": []
          }
         ]
       }

What can be reason? Is it possible that the reason is that I use localhost?

1 Like

Yes, it’s because of localhost.

For rapid prototyping/testing, I’d recommend ngrok. It’s an awesome way to create a publicly accessible URL without having to deploy to a third-party or anything like that.

Basically once installed, just ngrok http 8443, (assuming you are on port 8443) grab the public https link, and use that when registering your app.

1 Like

Thank you, I’ve never heard abour ngrok earlier , it seems to be great solution.

1 Like