# Homey HTTP Post\\Get in Java

**URL:** <https://community.homey.app/t/homey-http-post-get-in-java/52898>\
**Category:** Developers\
**Created:** [October 9, 2021, 10:33am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898 "2021-10-09T10:33:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil\_Alford](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/neil_alford/32/37373_2.png) [@Neil\_Alford](https://community.homey.app/u/Neil_Alford)\
**Post date:** [October 9, 2021, 10:33am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898/1 "2021-10-09T10:33:58Z")

</div>

Hi,

I’m having a go at creating my first Homey app in Java, trying to access energy usage from a smart meter. I have found and modified a python script which is correctly able to pull the data in by using http Post and Get requests, so now trying to recreate that in the Homey app, unfortunately, although I’m very experienced with C++ I’m totally new to Java!

I have found some examples that seems explain the sort of thing I want to do using the HttpRequest and HttpUrlConnection classes, however, trying to include the required java.net.http.\* in my project seems to fail, I don’t know if this is because I need to set something up differently, or maybe I can’t use those classes with Homey?

Hoping maybe someone could give me a hint, or maybe point me at some simple examples or tutorials of performing http requests from Homey? Only example I found on github was a fairly complex app that made it difficult for me to understand the basics of the http stuff.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [October 9, 2021, 10:44am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898/2 "2021-10-09T10:44:02Z")

</div>

Java_script_, I hope. Homey doesn’t run Java 😛

If you want to make HTTP requests from Javascript apps, you can use modules like [`http.min`](https://github.com/matjaz/node-http.min) to make life easier.

---

<div class="post-metadata">

**Author:** ![Neil\_Alford](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/neil_alford/32/37373_2.png) [@Neil\_Alford](https://community.homey.app/u/Neil_Alford)\
**Post date:** [October 9, 2021, 10:54am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898/3 "2021-10-09T10:54:39Z")

</div>

Ah yes, javascript!

That link for http.min is very useful, I had come across it being used but had been unable to find any information about it, however, that link explains it nicely and think I can see what I need to do!

Thanks.

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 9, 2021, 11:25am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898/4 "2021-10-09T11:25:48Z")

</div>

I’m using node-fetch right now, is there a good reason I should switch to http-min? I sometimes see people happily change from node-fetch to http-min, and sometimes the other way around.

With node-fetch I sometimes get a “TypeError: body user already for…” error, and I can’t figure out why. Do yoy think that could be solved by changing to http-min?

TIA!

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [October 9, 2021, 11:31am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898/5 "2021-10-09T11:31:28Z")

</div>

`node-fetch` is about 8MB in size, `http.min` is about 6K in size, so there’s that. It’s possible that `node-fetch` supports more features, but I doubt that any of them are typically required.

The error you’re getting is likely caused by something in your own code 😛

---

<div class="post-metadata">

**Author:** ![Le\_Cactus](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/le_cactus/32/9727_2.png) [@Le\_Cactus](https://community.homey.app/u/Le_Cactus)\
**Post date:** [October 9, 2021, 11:41am UTC](https://community.homey.app/t/homey-http-post-get-in-java/52898/6 "2021-10-09T11:41:24Z")

</div>

Thanks!

I’ll try the http-min 👍🏼
