# httpGet calls to Kepware REST API - IOError: Unexpected end of file from server

**URL:** <https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730>\
**Category:** Ignition\
**Created:** [August 23, 2019, 7:14pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730 "2019-08-23T19:14:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![whitson.brandon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/whitson.brandon/32/79016_2.png) [@whitson.brandon](https://forum.inductiveautomation.com/u/whitson.brandon)\
**Post date:** [August 23, 2019, 7:14pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/1 "2019-08-23T19:14:58Z")

</div>

I need some help with system.net.httpGet / Post

Background -  
Ignition 7.9.10  
Kepware 6.6.350.0

When I send the following  
r = system.net.httpGet("[http://127.0.0.1:57412/config/v1/project/channels/ENU](http://127.0.0.1:57412/config/v1/project/channels/ENU) Tower/",username="XXXXXXXXXX")

It returns - "IOError: Unexpected end of file from server"

however when I send  
r = system.net.httpGet("[http://127.0.0.1:57412/config/v1/project/channels/",username="XXXXXXXXX](http://127.0.0.1:57412/config/v1/project/channels/%22,username=%22XXXXXXXXX)")

I get a valid response from Kepware.  
Here's the strange part.... When I use Postman to send Get and Post calls everything works fine.  
I can post the responses from Potman but excluded them for now as they are extremely lengthy.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 23, 2019, 7:21pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/2 "2019-08-23T19:21:44Z")

</div>

Maybe you can spot the difference between Postman and the call that doesn’t work using Wireshark?

---

<div class="post-metadata">

**Author:** ![whitson.brandon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/whitson.brandon/32/79016_2.png) [@whitson.brandon](https://forum.inductiveautomation.com/u/whitson.brandon)\
**Post date:** [August 23, 2019, 7:25pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/3 "2019-08-23T19:25:37Z")

</div>

I was really trying to avoid packet capture...  
I'll fire up WireShark... Let you know what I find...

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 23, 2019, 7:38pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/4 "2019-08-23T19:38:11Z")

</div>

“IOError: Unexpected end of file from server” means the server (or something else) closed the connection for some reason. Since you can successfully make a request to a different URI it’s probably not something else, like a firewall or AV, and it’s KSE doing it for some reason.

If there were any logs to indicate why they’d be in KSE, not Ignition, so a packet capture seems like an easy next step.

---

<div class="post-metadata">

**Author:** ![whitson.brandon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/whitson.brandon/32/79016_2.png) [@whitson.brandon](https://forum.inductiveautomation.com/u/whitson.brandon)\
**Post date:** [August 23, 2019, 7:42pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/5 "2019-08-23T19:42:19Z")

</div>

Yep.... Packet Capture Done.....  
Here's what I found.....  
If I send with %20 in the spaces I get get a response....  
system.net.httpGet("[http://127.0.0.1:57412/config/v1/project/channels/ENU%20Tower/devices/Testing%20The%20API/meter\_groups/",username="XXX](http://127.0.0.1:57412/config/v1/project/channels/ENU%20Tower/devices/Testing%20The%20API/meter_groups/%22,username=%22XXX)")

If I send with spaces I get the error....  
system.net.httpGet("[http://127.0.0.1:57412/config/v1/project/channels/ENU](http://127.0.0.1:57412/config/v1/project/channels/ENU) Tower/devices/Testing The API/meter\_groups/",username="XXX")

ARG

Not a huge deal I can just run replace(" ","%20") on my url strings before passing them into the argument.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 23, 2019, 7:52pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/6 "2019-08-23T19:52:33Z")

</div>

You might be able to use python’s urlencode function: [https://docs.python.org/2/library/urllib.html#urllib.urlencode](https://docs.python.org/2/library/urllib.html#urllib.urlencode)

You’ll have to see if it’s actually part of the version of Jython we ship though.

---

<div class="post-metadata">

**Author:** ![whitson.brandon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/whitson.brandon/32/79016_2.png) [@whitson.brandon](https://forum.inductiveautomation.com/u/whitson.brandon)\
**Post date:** [August 23, 2019, 8:03pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/7 "2019-08-23T20:03:31Z")

</div>

I was kinda expecting the function call to format the url properly?  
The doc just says to pass it a url...  
All though the second code snippet does have the %20 in the url...

Any chance we could have it put in as a bug...  
Honestly I'm surprised no one else has ever had this issue..  
Must not be a commonly used function. - Or I'm just a moron

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 23, 2019, 8:04pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/8 "2019-08-23T20:04:45Z")

</div>

It’s very commonly used, but spaces in URLs are less common I guess.

and FWIW, a string with spaces in it is not technically a URL, because URLs cannot contain spaces.

---

<div class="post-metadata">

**Author:** ![whitson.brandon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/whitson.brandon/32/79016_2.png) [@whitson.brandon](https://forum.inductiveautomation.com/u/whitson.brandon)\
**Post date:** [August 23, 2019, 8:05pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/9 "2019-08-23T20:05:28Z")

</div>

Confirmed - Moron Status.... 😜

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 23, 2019, 8:07pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/10 "2019-08-23T20:07:08Z")

</div>

I do think it would be nice if it URL-encoded things for you… but then if someone passed an already encoded / proper URL, it would get double-encoded…

---

<div class="post-metadata">

**Author:** ![whitson.brandon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/whitson.brandon/32/79016_2.png) [@whitson.brandon](https://forum.inductiveautomation.com/u/whitson.brandon)\
**Post date:** [August 23, 2019, 8:09pm UTC](https://forum.inductiveautomation.com/t/httpget-calls-to-kepware-rest-api-ioerror-unexpected-end-of-file-from-server/27730/11 "2019-08-23T20:09:00Z")

</div>

Right...

Well thanks for the help Kevin....
