# POST + https request in EDGE

**URL:** <https://community.smartthings.com/t/post-https-request-in-edge/247583>\
**Category:** Writing Edge Drivers\
**Created:** [September 9, 2022, 10:02pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583 "2022-09-09T22:02:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 9, 2022, 10:02pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/1 "2022-09-09T22:02:53Z")

</div>

Hi,

What is the proper way to do a https POST request inside of an EDGE driver. I tried to do this:

```auto
   local https = require("ssl.https")
   local _, code = https.request({
      url=url,
      method="POST",
      protocol="any",
      options = {"all"},
      verify="none",
      headers = {
         ["Content-Type"] = "application/x-www-form-urlencoded"
      },
      sink=ltn12.sink.table(response)
   })

```

I can verify that the post https request is correct using curl, but the request in the driver seems to fail.  
What am I missing?

Thanks,  
Jose

---

<div class="post-metadata">

**Author:** ![RBoy](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/rboy/32/62677_2.png) [@RBoy](https://community.smartthings.com/u/RBoy)\
**Post date:** [September 9, 2022, 11:20pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/2 "2022-09-09T23:20:34Z")

</div>

SmartThings has disabled https, dns and public ip on edge. Edge isn’t ready for primetime yet as a viable option to replace groovy unfortunately.

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 1:00am UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/3 "2022-09-10T01:00:14Z")

</div>

Hm… That’s unfortunate. Is there a reason why this is? When will it be turned on? In some ways I’m glad that’s true. This one was a head scratcher.

Regards,  
Jose

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 10, 2022, 4:40am UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/4 "2022-09-10T04:40:05Z")

</div>

https absolutely works in Edge drivers; I’ve used it.

I think you were just missing the cosock.asyncify instead of require:

```auto
local https = cosock.asyncify "ssl.https"

```

---

<div class="post-metadata">

**Author:** ![RBoy](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/rboy/32/62677_2.png) [@RBoy](https://community.smartthings.com/u/RBoy)\
**Post date:** [September 10, 2022, 11:58am UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/5 "2022-09-10T11:58:22Z")

</div>

I didn’t realize they had enabled it. Wonder when they’ll enable the rest

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 3:27pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/6 "2022-09-10T15:27:34Z")

</div>

@TAustin Thank you for your post. I should have mentioned that I tried both with asyncify and without. I must have a mistake but I can’t seem to find it. The exact same url works in curl but not in the code. On a related note, it’s very difficult to debug this. All the returns are nil…

Any other deas?

Thanks

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 10, 2022, 4:05pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/7 "2022-09-10T16:05:29Z")

</div>

What error are you seeing in the log?

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 7:00pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/8 "2022-09-10T19:00:09Z")

</div>

@TAustin I don’t get any errors in the log at all. All return vals are nil and I don’t get a 200 return code…

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 10, 2022, 7:11pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/9 "2022-09-10T19:11:49Z")

</div>

Is the target receiving the message? Just trying to understand if it’s a problem sending or a problem receiving the response.

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 7:56pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/10 "2022-09-10T19:56:24Z")

</div>

@TAustin I can’t tell if the target is receiving since I am calling a REST api. What I mean is that I don’t get anything useful from the https.request call itself. The call completes but the return variables are all nil. At least I think they are.

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 10, 2022, 8:15pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/11 "2022-09-10T20:15:42Z")

</div>

I noticed that you are including Content-Type header, however you don’t appear to be sending any body data with your message. If the REST api you are using isn’t expecting any, then try removing that header. Otherwise, if you are sending data in the body part of the message, then you should also include a Content-Length header and of course this:

> source = ltn12.source.string(sendbody)

If you want, you can send me a direct message with the URL so I can check that. Otherwise, have you tried plugging that exact url into a browser to confirm that it works ok?

EDIT: One other thing, I usually include this header in all requests - body data or not:

> Accept = \*/\*

---

<div class="post-metadata">

**Author:** ![lmullineux](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/lmullineux/32/163169_2.png) [@lmullineux](https://community.smartthings.com/u/lmullineux)\
**Post date:** [September 10, 2022, 8:22pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/12 "2022-09-10T20:22:12Z")

</div>

Is the URL you are calling on the local LAN or the internet?

Edge drivers only allow local LAN

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 9:39pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/13 "2022-09-10T21:39:36Z")

</div>

@TAustin OK. I will give that a try.  
@lmullineux Are you sure Edge drivers only allow local LAN? If so, that seems very restrictive. Where is this limitation documented?

---

<div class="post-metadata">

**Author:** ![csstup](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/csstup/32/141481_2.png) [@csstup](https://community.smartthings.com/u/csstup)\
**Post date:** [September 10, 2022, 9:45pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/14 "2022-09-10T21:45:37Z")

</div>

> [@josep1972](#):
>
> Where is this limitation documented?

> **[LAN Edge Device Driver Development Guide | Developer Documentation | SmartThings](https://developer.smartthings.com/docs/devices/hub-connected/lan)**
>
> SmartThings Edge Device Drivers introduce the ability to write far more

 ![image](https://global.discourse-cdn.com/smartthings/original/3X/0/4/048e5195c7bde4b2e9ebf646a23c93be7b0500da.png)

Documented, but could be more obviously called out as “ONLY local LAN”.

---

<div class="post-metadata">

**Author:** ![lmullineux](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/lmullineux/32/163169_2.png) [@lmullineux](https://community.smartthings.com/u/lmullineux)\
**Post date:** [September 10, 2022, 9:55pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/15 "2022-09-10T21:55:00Z")

</div>

Edge is only for local device control - there are other paradigm and approaches for internet devices

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 9:56pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/16 "2022-09-10T21:56:34Z")

</div>

@csstup Wow that’s pretty annoying, actually. In a groovy DHT you could call external addresses. The functionality has gone backwards in this respect. I suppose the claim will be that it has something to do with security, but it seems to me https requests to outside addresses are secure(?). Also, it would be good if the http request calls would return something saying that the address is not accessible or something instead of just nothing.

Anyhow, thank you for the help.

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 10:03pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/17 "2022-09-10T22:03:04Z")

</div>

@lmullineux Can you elaborate, please?

---

<div class="post-metadata">

**Author:** ![lmullineux](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/lmullineux/32/163169_2.png) [@lmullineux](https://community.smartthings.com/u/lmullineux)\
**Post date:** [September 10, 2022, 10:11pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/18 "2022-09-10T22:11:09Z")

</div>

Sure, smartthings supports many different device types. Edge is intended only for hub connected devices.

 ![Screenshot_20220910-230803](https://global.discourse-cdn.com/smartthings/original/3X/0/1/010975d6457ca6f0d619c5b7fe99e79d5750d78f.png)

> **[Device Basics | SmartThings Developers](https://developer-preview.smartthings.com/docs/devices/device-basics/)**
>
> Devices are physical products that connect to and operate with the SmartThings Platform.

You can build internet connected devices, and smartapps still on the new platforms. Just like you could with groovy, only difference is now you have to host them yourself.

---

<div class="post-metadata">

**Author:** ![lmullineux](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/lmullineux/32/163169_2.png) [@lmullineux](https://community.smartthings.com/u/lmullineux)\
**Post date:** [September 10, 2022, 10:13pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/19 "2022-09-10T22:13:52Z")

</div>

If you really want to use edge (although this is not what Samsung intended) you can use a proxy installed on a device on your network (e.g a raspberry pi) to get your requests out onto the internet. @TAustin had some software that you can use

---

<div class="post-metadata">

**Author:** ![josep1972](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/josep1972/32/123825_2.png) [@josep1972](https://community.smartthings.com/u/josep1972)\
**Post date:** [September 10, 2022, 10:43pm UTC](https://community.smartthings.com/t/post-https-request-in-edge/247583/20 "2022-09-10T22:43:19Z")

</div>

@lmullineux I see what you mean. In my case I am trying to add functionality to the Flair vents and pucks. I had it all working with groovy and I am now porting it to Lua. I suppose I would have had to choose to create a Cloud Connected Device and implement all the auth stuff. That’s a lot of work for just 3 devices in my case. It’s more work than just creating an Edge device, since porting from groovy is proving to be pretty easy. It’s still a little unclear as to why an Edge device cannot access the outside world. Is it _really_ a security concern? As you point out, I will have to end up creating a simple “API proxy” that sits inside my LAN and translates from the Edge device to the API…I will probably just write it in php. Simple enough. A little annoying, but it will still be less complexity than supporting a “Connected & Secure Cloud” using Schema, etc. That route really seems to be for more of a professional solution rather than the part time software person.

Regards,  
Jose

[Next page](https://community.smartthings.com/t/post-https-request-in-edge/247583.md?page=2)
