SmartThings CLI apps:update Type Error (reading 'url')

Hi,

Currently I can’t edit my app created via SmartThings CLI apps:create with following result:

smartthings apps:update
───────────────────────────────────────────────────────

Display Name App Id

───────────────────────────────────────────────────────
1 SmartHome ----
───────────────────────────────────────────────────────
? Select an app. 1
? Choose an action. Edit App Update.
TypeError: Cannot read properties of undefined (reading ‘url’)

Please be kindly advise.

Thanks in advance.

Best Regards,
Henoch

Hi, @henoch.setiadi

What kind of app did you create? Webhook/Lambda or OAuth-In app?
What are you trying to update? I ask because you can update it using a JSON file as input as well, instead of using the helper.

I used the same command and saw the same error, so I’ll ask the engineering team about it, but in the meantime, we can check how you can edit your app to continue with your tests.

Hi @nayelyz ,

I used OAuth-In App and tried to update Target URL. Does updating with JSON file can be done with same cli command?

Thanks in advance.

Hi, @henoch.setiadi
I’ve been doing some tests, and despite sending the correct properties needed for a target URL, it gets ignored.
So, for now, I suggest you create another app with the correct targetURL so you can continue with your tests while we investigate this further with the engineering team.

Hi, @henoch.setiadi

The engineering team mentioned the correct structure to update the app is the following:

{
    "appName": "...",
    "appType": "API_ONLY",
    "principalType": "LOCATION",
    "classifications": [
        "CONNECTED_SERVICE"
    ],
    "displayName": "OAuth Integration",
    "description": "Description",
    "apiOnly": {
        "targetUrl": "https://..."
    }
}

Things like the “appName” depend on the current values of your app.
Just as an FYI, you’ll see this result for the app in the “apiOnly” property:

"apiOnly": {
        "subscription": {
            "targetUrl": "https://...",
            "targetStatus": "PENDING"
        }
}

That’s the input I was using, but this is the value I mentioned being ignored. This is to avoid confusion in the future.

Note: Registering the targetURL will send a POST request to that endpoint with the confirmationURL, which you need to copy and paste in the browser or make a GET request using it. This is to “verify” the app so it can receive requests with the subscription events.

Ah I was wondering if you had been caught out by that. It’s not at all obvious, and it doesn’t happen with the other app types.

Fortunately I knew to look at the apps endpoint definition in the Core SDK to see what is going on. Indeed that folder as a whole is a mine of information about the API.

Hi, @henoch.setiadi
Just following up on the initial error of “TypeError: Cannot read properties of undefined (reading ‘url’)”.
The engineering team made a correction to the CLI, so, it should work correctly in this version without a file as the input:

1 Like

Thanks @nayelyz just tested and it is working, but I can’t find way to update Redirect URI, do you know where it should be?

smartthings apps:update
───────────────────────────────────────────────────────

Display Name App Id

───────────────────────────────────────────────────────
1 SmartHome 00000000-0000-0000-0000-000000000000
───────────────────────────────────────────────────────
? Select an app. 1
? Choose an action. Edit App Update.
? App Update (Use arrow keys)
Edit Display Name: SmartHome
Edit Description: Windows Service to manage SmartThings Devices.
Edit Icon Image URL: undefined
Edit Target URL: https://cdcab8a73e37.ngrok-free.app
──────────────
Help
Finish editing App Update.
Cancel

The CLI handles the ‘oauth’ bits of the apps separately so look at smartthings apps:oauth and smartthings apps:oauth:update.

1 Like

Thanks @orangebucket .