# Connection failure NETWORK REQUEST

**URL:** <https://forums.solar2d.com/t/connection-failure-network-request/349606>\
**Category:** Announcements\
**Created:** [March 16, 2019, 3:52am UTC](https://forums.solar2d.com/t/connection-failure-network-request/349606 "2019-03-16T03:52:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![diego\_martinez93](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/d/a587f6/32.png) [@diego\_martinez93](https://forums.solar2d.com/u/diego_martinez93)\
**Post date:** [March 16, 2019, 3:52am UTC](https://forums.solar2d.com/t/connection-failure-network-request/349606/1 "2019-03-16T03:52:20Z")

</div>

Hi. i have this error when i try get data from the server. Can you help me?. tanks

function db.download\_users()

&nbsp;&nbsp;&nbsp;&nbsp;local URL = IP…"/app1Api/User"

&nbsp;&nbsp;&nbsp;&nbsp;local function networkListener( event )

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (event.isError) then

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(event.response)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local decodedData = json.decode(event.response)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(decodedData.error ~= nil) then

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for k,v in pairs(decodedData) do

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;network.request(URL, “GET”,networkListener)

end

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [March 18, 2019, 8:27pm UTC](https://forums.solar2d.com/t/connection-failure-network-request/349606/2 "2019-03-18T20:27:52Z")

</div>

What is the variable IP?

What is the value of event.isError?

What is the value of event.response?

Is there an error member of your expected JSON in decodedData?

Honestly, you can learn a lot more by making this simple change:

```
function db.download\_users() local URL = IP.."/app1Api/User" local function networkListener( event ) print( json.prettify( event ) ) if (event.isError) then print(event.response) else local decodedData = json.decode(event.response) if(decodedData.error ~= nil) then else for k,v in pairs(decodedData) do end end end end network.request(URL, "GET",networkListener) end

```

Dumping the whole event table will tell you a lot. Is the URL timing out or bad? Is the web server on the other end working but giving you a 404 error because the page doesn’t exist? Help us with that information so we can help you…

Rob

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [March 18, 2019, 8:27pm UTC](https://forums.solar2d.com/t/connection-failure-network-request/349606/3 "2019-03-18T20:27:52Z")

</div>

What is the variable IP?

What is the value of event.isError?

What is the value of event.response?

Is there an error member of your expected JSON in decodedData?

Honestly, you can learn a lot more by making this simple change:

```
function db.download\_users() local URL = IP.."/app1Api/User" local function networkListener( event ) print( json.prettify( event ) ) if (event.isError) then print(event.response) else local decodedData = json.decode(event.response) if(decodedData.error ~= nil) then else for k,v in pairs(decodedData) do end end end end network.request(URL, "GET",networkListener) end

```

Dumping the whole event table will tell you a lot. Is the URL timing out or bad? Is the web server on the other end working but giving you a 404 error because the page doesn’t exist? Help us with that information so we can help you…

Rob
