I have a server that I query regularly that holds our ERP software. I get information from the ERP server via SQL something like below:
shared.oodbapi.fetchDataSQL("SELECT TOP 5 clockNumber FROM Employees")
Which I can then bind to a component to display the results.
The weird part is that when I add a binding like the above query to a component it fails saying I can't POST. If I execute the same statement in the designer script console it works and no error occurs; it works as expected.
The ERP server requires an HTTPS connection so I'm not sure why I can POST in the console but not in the designer.
This is the error that I get from perspective:
Description
Traceback (most recent call last):
File "<transform>", line 2, in transform File "<module:shared.oodbapi>",
line 48, in fetchDataSQL at com.inductiveautomation.ignition.common.script.builtin.http.JythonHttpClient.send(JythonHttpClient.java:94) at
com.inductiveautomation.ignition.common.script.builtin.http.JythonHttpClient.post(JythonHttpClient.java:309) 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 https://odyssey.lethiron.com/odyssey/api/FetchData/SQL
the function definition
def fetchDataSQL(query, limit=1800):
"""fetch data from Odyssey using SQL
params:
query: str - SQL query to execute
limit: int - number of records to return
returns:
data: list - list of dicts with keys being each field in the query
"""
client = system.net.httpClient()
url = "{}FetchData/SQL".format(BASE_URL)
company = system.tag.readBlocking(COMPANY_TAG)[0].value
params = {
"SQLQuery": query,
"Page": 1,
"BatchSize": limit,
"CompanyID": company,
"APIKey": API_KEY,
}
response = client.post(url, data=params) # its complaining here
if response.json["Success"]:
return list(response.json["DataSetOut"]["tTemptable"])
raise BadOdysseyQueryError(response.json["ErrorMessage"])
Any idea why this is happening? Thanks in advance.