SmartApp Config response rejected without explanation

Developing a SmartApp… I have it registered and deployed to Test. When I try to install the SmartApp on my phone it triggers a Config/Initialize call to my service. My service responds with the exact JSON message that appears in the documentation (below) which I have verified with Postman. However, the SmartThings app always gives the error “Something went wrong. Please try to install the SmartApp again.” I’ve checked Live Logging but it doesn’t give any info about this call, just has unrelated control events. Any ideas?

image

I’ve only really dabbled in this area, but I’ve never actually taken much notice of ‘Live Logging’. I’ve always found it more interesting to see what my app is seeing and doing.

So can you see that your app is definitely receiving the CONFIGURATION/INITIALIZE request from ST and outputting the required response with a Content-Type header as valid JSON, all without crashing?

If so is this being followed up by a fresh call from ST with the CONFIGURATION/PAGE request? If yes then we move on a phase.

2 Likes

Hi @wpierson, Could you share how you configure your smartapp?

1 Like

Yes, my app receives the Configuration/Initialize call from ST and then responds to it. I’m able to see the response by replicating the call with postman. Below are the JSON response and headers. ST doesn’t make a Config/Page request as it fails after the Initialize response.

image

Could you provide more detail on what you’d like to see? I just have a web service which is sending a JSON response back to ST that exactly matches what is in the documentation.

OK. I do notice there is an r in the permissions array. Permissions are normally more like r:devices:* with varying number of : separated fields. I’ve not seen one that is just r. Usually problems with permissions manifest themselves in the last stage of installation when mismatches with the whitelist are an issue, but it could perhaps be an invalid syntax at this stage.

I understand I think this is the lifecycle that you are doing Lifecycles | Developer Documentation | SmartThings based on the documentation your response doesn’t have some attributes as "lifecycle": "CONFIGURATION",

For this type of integration, we recommend using the SmartApp SDK, but on Community, there is another user that has created SmartApp without the SDK Building First SmartApp for Dummies you can use it as references.

Thanks for your reply… You’re right, I was trying different options for permissions to see if I could get it to work. Here is the response without permissions that matches the documentation. It still doesn’t work.

image

Thanks for your reply… I’m working through the documentation at Configuration | Developer Documentation | SmartThings . The call from ST to my service has the “lifecycle”: “CONFIGURATION” attribute. My response is not supposed to have this attribute in it. I have exactly matched what the documentation says should be returned to ST, yet it fails with no explanation. Can your engineers check the logs to see why it is failing?

It certain looks OK. I’d probably test without the slashes in the name and description just because escaping and unescaping of characters provides an unnecessary distraction at this stage. You never quite know what the underlying data is.

Thanks… I took the slashes out and it still fails. Any ideas?

image

@wpierson let me test it, one question Did you receive the page request? or does the error occur during the INITIALIZE phase?

I’m back. I was testing, and it is working correctly. I used examples from both the INITIALIZE phase and the PAGE phase in the official documentation. So, the possible error here is that you aren’t responding to the second phase, which could be causing the error if not please let me know to check what is happening.

I use this code to test, so maybe can help you the different phases:

app.post('/', (req: Request, res: Response) => {
  const { lifecycle } = req.body;
  if ( lifecycle === "CONFIGURATION"){
    const { configurationData }  = req.body
    const phase = configurationData?.phase;
    if( phase  === "INITIALIZE"){
      return res.json(initialize_response);
    }
    if( phase === "PAGE"){
      return res.json(page_response);
    }
  }
});

Thanks Alejandro… you’re right, it was working for the Initialize call but failing on the Page call. It would be helpful for diagnosing these issues if the Live Logging showed this information. Thanks for your help!

1 Like