# system.net.httpClient() IOException when used in uploadFile Component

**URL:** <https://forum.inductiveautomation.com/t/system-net-httpclient-ioexception-when-used-in-uploadfile-component/84310>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [January 16, 2024, 9:44am UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-ioexception-when-used-in-uploadfile-component/84310 "2024-01-16T09:44:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [January 16, 2024, 9:44am UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-ioexception-when-used-in-uploadfile-component/84310/1 "2024-01-16T09:44:53Z")

</div>

Hi all ,

I'm creating an API where I can upload a file from Ignition for processing.

The issue is, when I run this function from the script console it works as expected.

The API currently returns the json data in the request body as the response.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/0/403d527d77eac1e73b603f7f285192bbf7cb1592.png)

When I try and run the same script in the fileUpload Component I get a IOException Error.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/a/8a9eaa486ac0cd31c1c3769784103ea7674ab0ed.png)

```auto
Error running action 'component.onFileReceived' on Audit Log/TestUpload@D/root/FileUpload: Traceback (most recent call last): File "<function:runAction>", line 3, in runAction File "<module:Utilities.customFunctions>", line 24, in getAPIData at com.inductiveautomation.ignition.common.script.builtin.http.JythonHttpClient.send(JythonHttpClient.java:103) at com.inductiveautomation.ignition.common.script.builtin.http.JythonHttpClient.post(JythonHttpClient.java:318) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.io.IOException: java.io.IOException: Unable to POST http://127.0.0.1:5000/data-upload

```

Here is the function

```auto
def getAPIData():
	
	url="http://127.0.0.1:5000/data-upload"
	client = system.net.httpClient()
	response=client.post(
			url=url,
			headers={"Content-Type":"application/json"},
			data={"test":"data"})
	return response

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 16, 2024, 5:08pm UTC](https://forum.inductiveautomation.com/t/system-net-httpclient-ioexception-when-used-in-uploadfile-component/84310/2 "2024-01-16T17:08:54Z")

</div>

> [@liam1](#):
>
> `Unable to POST http://127.0.0.1:5000/data-upload`

127.0.0.1 is `localhost`. Is the gateway running on the same computer as you're executing your test in the script console? Does it have the same service running? Is it also running on port 5000?
