# Again... issues with endpoints

**URL:** <https://community.smartthings.com/t/again-issues-with-endpoints/48970>\
**Category:** Connected Things\
**Created:** [May 28, 2016, 11:52pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970 "2016-05-28T23:52:49Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [May 31, 2016, 1:46am UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/22 "2016-05-31T01:46:07Z")

</div>

HAM Bridge can execute any script via Applescript, shell script, or Python, but most folks using it simply want a GET endpoint to their devices.

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [May 31, 2016, 2:00am UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/23 "2016-05-31T02:00:18Z")

</div>

> [@scottinpollock](#):
>
> but most folks using it simply want a GET endpoint to their devices.

Understandable. That’s how we had it documented for a time, but we are trying to follow the best practice of having inbound change requests use the PUT method and storing the token in the header, rather than in the URL.

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [May 31, 2016, 2:11am UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/24 "2016-05-31T02:11:04Z")

</div>

I suppose I have no problem with that, just show me how it works.

But note this complicates access for what I would guess is a lot of folks using things like iRule and Tasker. This is probably why IFTTT’s Maker channel uses GET.

So… you might want to rethink that. Ideally, we should have the choice to use either method.

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 1, 2016, 10:28pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/25 "2016-06-01T22:28:01Z")

</div>

> [@jody.albritton](#):
>
> I have an endpoint SmartApp that will probably work for your needs. I need to simplify the instructions this weekend, and then I will update this thread.

Hey Jody…

Any traction on this?

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 2, 2016, 12:23am UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/26 "2016-06-02T00:23:00Z")

</div>

I have not forgotten about you. Apologies for the delay, but I am still working on it.

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 15, 2016, 9:49pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/27 "2016-06-15T21:49:14Z")

</div>

> [@jody.albritton](#):
>
> I have not forgotten about you

Feels like you have…

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 15, 2016, 10:04pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/28 "2016-06-15T22:04:48Z")

</div>

Sorry for the delay.

Please see the source here:

> **[jodyalbritton/apismartapp](https://github.com/jodyalbritton/apismartapp)**
>
> apismartapp - API SMARTAPP PROTOTYPE

Install the app and then enable oAuth in the settings. In the IDE, install the app in the simulator and grab the token and endpoint url.

You should be able to call [yourEndpoint.ide.smartthings.com/api/smartapps/xxxxx-xxxx-xxxx--xxxx/devices/switches](http://yourEndpoint.ide.smartthings.com/api/smartapps/xxxxx-xxxx-xxxx--xxxx/devices/switches)

Pass the token in the header with something like postman for google chrome. You will get a list of the switches that you have selected and the available commands.

PUT /devices/switches/xxxx-xxxx-xxxx-xxxx/off  
PUT /devices/switches/xxxx-xxxx-xxxx-xxxx/on

while passing the token in the header.

---

<div class="post-metadata">

**Author:** ![tgauchat](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/tgauchat/32/49516_2.png) [@tgauchat](https://community.smartthings.com/u/tgauchat)\
**Post date:** [June 15, 2016, 10:12pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/29 "2016-06-15T22:12:42Z")

</div>

> [@jody.albritton](#):
>
> You will get a list of the switches that you have selected and the available commands.

- Aren’t SmartApps supposed to explicitly check and allow _only_ the Commands applicable to the Capability selector of the `input` preferences?

- Isn’t this best done by just defining explicit Endpiont mappings, instead of having all the commands exposed as Endpoints.

- Or, even better, shouldn’t the Platform only expose the appropriately authorized Command and Attribute Endpoints, since the Platform has mechanisms to know what the Device selection input filter is…?

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 15, 2016, 10:18pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/30 "2016-06-15T22:18:00Z")

</div>

> [@tgauchat](#):
>
> Aren’t SmartApps supposed to explicitly check and allow only the Commands applicable to the Capability selector of the input preferences?

Endpoints should not accept arbitrary commands. There is a check for supported commands. More explicit control of permissions might be required to get this published, but this a starter template that exposes everything in a sane way.

```
def listDeviceCommands() {
    def type = params.deviceType
    def id = params.id
    def device = settings[type]?.find{it.id == id}
    def result = []
    if(!device) {
        httpError(404, "Device not found")
    } else {
        device.supportedCommands?.each {
            result << ["command" : it.name, "params" : [:]]
        }
    }
    log.debug "Returning COMMANDS: $result"
    result
}

```

---

<div class="post-metadata">

**Author:** ![tgauchat](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/tgauchat/32/49516_2.png) [@tgauchat](https://community.smartthings.com/u/tgauchat)\
**Post date:** [June 15, 2016, 10:36pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/31 "2016-06-15T22:36:01Z")

</div>

> [@jody.albritton](#):
>
> Endpoints should not accept arbitrary commands. There is a check for supported commands.

Right… this code exposes ALL “supported commands”, not _just_ those explicitly in the **Capability** the user was prompted with.

The U of M study example was that a “supported command” for a Lock Device includes `lock(), unlock(), setLockPIN(), ...`, even though this Device was selected as a part of a list filtered on Capability **Battery** (i.e., read-only Attribute `battery`).

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 15, 2016, 10:40pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/32 "2016-06-15T22:40:35Z")

</div>

> [@jody.albritton](#):
>
> You should be able to call [yourEndpoint.ide.smartthings.com/api/smartapps/xxxxx-xxxx-xxxx--xxxx/devices/switches](http://yourEndpoint.ide.smartthings.com/api/smartapps/xxxxx-xxxx-xxxx--xxxx/devices/switches)

What is “xxxxx-xxxx-xxxx–xxxx”

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 15, 2016, 10:41pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/33 "2016-06-15T22:41:38Z")

</div>

That is your installation ID. You can see find the full URL in the IDE Simulator, or from using the oAuth flow in postman.

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 15, 2016, 10:45pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/34 "2016-06-15T22:45:54Z")

</div>

> [@jody.albritton](#):
>
> You should be able to call [yourEndpoint.ide.smartthings.com/api/smartapps/xxxxx-xxxx-xxxx--xxxx/devices/switches](http://yourEndpoint.ide.smartthings.com/api/smartapps/xxxxx-xxxx-xxxx--xxxx/devices/switches)

> [@jody.albritton](#):
>
> That is your installation ID

So what is “yourEndpoint”? GET or PUT? What is the key for the token value? I assumed it was token, but am getting access denied.

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 15, 2016, 10:49pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/35 "2016-06-15T22:49:13Z")

</div>

> [@scottinpollock](#):
>
> So what is “yourEndpoint”? GET or PUT? What is the key for the token value? I assumed it was token, but am getting access denied.

The endpoint will be different depending on the server you are on.

if you look in the simulator you will see something like

API Endpoint: [https://graph.api.smartthings.com/api/smartapps/installations/XXXXX-YOUR](https://graph.api.smartthings.com/api/smartapps/installations/XXXXX-YOUR) ID-XXXXX

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 15, 2016, 10:53pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/36 "2016-06-15T22:53:38Z")

</div>

> [@jody.albritton](#):
>
> The endpoint will be different depending on the server you are on.

Let’s go at this from another side. My endpoint is:

[https://graph.api.smartthings.com/api/smartapps/installations/myID](https://graph.api.smartthings.com/api/smartapps/installations/myID)

given this, what is the url to get the list of devices?

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 15, 2016, 11:04pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/37 "2016-06-15T23:04:17Z")

</div>

GET

[https://graph.api.smartthings.com/api/smartapps/installations/myID/devices](https://graph.api.smartthings.com/api/smartapps/installations/myID/devices)

And the token is passed in the header

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 15, 2016, 11:29pm UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/38 "2016-06-15T23:29:01Z")

</div>

> [@jody.albritton](#):
>
> [https://graph.api.smartthings.com/api/smartapps/installations/myID/devices](https://graph.api.smartthings.com/api/smartapps/installations/myID/devices)

Actually, dont you mean:  
[https://graph.api.smartthings.com/api/smartapps/installations/myID/devices/switches](https://graph.api.smartthings.com/api/smartapps/installations/myID/devices/switches)

Not “[https://graph.api.smartthings.com/api/smartapps/installations/myID/devices](https://graph.api.smartthings.com/api/smartapps/installations/myID/devices)”

or whatever you meant by:

[yourEndpoint.ide.smartthings.com/api/smartapps/myID/devices/switches](http://yourEndpoint.ide.smartthings.com/api/smartapps/myID/devices/switches)

Anyway… I did successfully get the list with the first url above, but no available commands:  
{  
“id”: “a\_device\_ID”,  
“name”: “Intermatic CA5100”,  
“displayName”: “Amplifiers”  
}

but executing:

PUT /api/smartapps/installations/myID/devices/switches/deviceID/on HTTP/1.1  
Host: [graph.api.smartthings.com](http://graph.api.smartthings.com)  
token: myTOKEN  
Cache-Control: no-cache

returns:  
{“error”:true,“type”:“SmartAppException”,“message”:“Not Found”}

---

<div class="post-metadata">

**Author:** ![jody.albritton](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/jody.albritton/32/220661_2.png) [@jody.albritton](https://community.smartthings.com/u/jody.albritton)\
**Post date:** [June 16, 2016, 3:38am UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/39 "2016-06-16T03:38:34Z")

</div>

After you get the list of devices, you need to query the individual device

> **[SmartThings.](https://www.smartthings.com/api/smartapps/myID/devices/switches/deviceID)**
>
> Add a little smartness to your things.

---

<div class="post-metadata">

**Author:** ![scottinpollock](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/scottinpollock/32/67273_2.png) [@scottinpollock](https://community.smartthings.com/u/scottinpollock)\
**Post date:** [June 16, 2016, 9:15am UTC](https://community.smartthings.com/t/again-issues-with-endpoints/48970/40 "2016-06-16T09:15:47Z")

</div>

[http://www.golfwrx.com/forums/public/style\_emoticons/default/russian\_roulette.gif](http://www.golfwrx.com/forums/public/style_emoticons/default/russian_roulette.gif)

[Previous page](https://community.smartthings.com/t/again-issues-with-endpoints/48970.md?page=1)
