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.
When I try and run the same script in the fileUpload Component I get a IOException Error.
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
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