Creating SmartApp using Postman?

Hi. I lately joined the smart things developer workspace. I have been working with SmartThings API lately and trying to create locations,rooms, rules and etc. After creating a profile I wanted to create Smart App using the request of it in the documentaion of the API but when I enter the request which my choose is the webhook smart app, I receive Target Timeout Error for my request. What should I do? Is there anything wrong with my target url of webhook?

Hello @Kiarash_Kianian, could you please provide me with more information about your steps, the payload you are sending, the endpoint you are using (just to confirm), and your target URL? But also, remember that you can create a SmartApp through the Developer Workspace, which is quite easy.
Have you already checked this tutorial?

2 Likes

The body of the request is below:

{
“appName”: “tempreture_sensor”,
“displayName”: “TempretureSensor”,
“description”: “A Sensor which handles the tempreture of the room based on the Presence”,
“appType”: “WEBHOOK_SMART_APP”,
“classifications”: [
“AUTOMATION”
],
“webhookSmartApp”:{
“targetUrl”:“https://sapp.techlife.pw
}

}

I wanted to know that just using postman for creating profiles, locations, rules, and others is enough to then use the API doc to send request to create app? or I must create an app using SDK before

Because I want to install a device in the Device API part but it needs an installed app ID which means that I should create an app first but I do not know how to create the app using my webhook endpoint

I tried to create a Webhook SmartApp without using the Developer Workspace about a year ago. The Developer Workspace was much improved over what it used to be but still not a pleasant experience. Generally speaking I try to avoid anything that involves the Samsung Developers site as they just seem to make things unnecessarily complicated to my mind. Even reaching the Developer Workspace can be a battle sometimes, and one I’ve often lost to broken authentication and redirect links.

I would have used the CLI rather than Postman but it is the same idea. I found I could successfully register the app but there was no way to deploy the app once I had done so (what we used to call ‘publishing the app to a Location’ on the legacy platform). A number of other users had the same experience. I don’t think anything has changed since then, or if it has it hasn’t been picked up for the CLI.

I believe my request looked similar to yours except I had an ‘oauth’ section for permissions. It was a while ago though and I don’t have any details of what I did.

I am wondering if by ‘timeout’ they mean the target URL doesn’t return the expected response, rather than not being reachable. Do you see a request reach your app?

I haven’t created the app yet. As the steps in the Rest API Docs of the implementation, it is said that after creating locations, rooms, rules and profiles you can create an app and then install a virtual device.
I was wondering that what should I do in here? Are these just the steps I need or I’m taking it in a wrong way

That is likely to be the problem. When you ‘create an app’ in the SmartThings API you are really registering an already existing app. There doesn’t have to be a fully functioning app on the target URL but it needs to be able to respond to a ‘confirmation’ request appropriately and then you need to make a request to a confirmation URL that was included in that request within a short window to verify that you have permission to use the app. You can do this manually or if you don’t mind who registers your app you can have the app do it automatically.

You mean that before I create the app using the request from the api I should create it in my target URL?Like using SDK in link below?

I rather feared I’d regret writing stuff without checking my facts after so long. I am going to correct myself here.

It is most definitely possible to create an app in the API without a functional app on the targetUrl. The app gets created with a targetStatus of PENDING.

What I am unclear about is whether creating an app in the API (with a POST to /apps) actually triggers the registration process as well or whether it has to be triggered separately.

What is true is that they rather anticipate you having prepared the code for your SmartApp first.