I have an API GET function where the response contains some characters that are non-ASCII but are UTF-8 characters. Some examples of these characters are: –,¼,½,¾,“,”,Â,â,®. The function works fine when it has only a "tag" action, but when I add a "script" action to the function, I get the following error (with customer data redacted) and the script does not execute.
com.kyvislabs.api.client.common.exceptions.APIException: Error handling script action
at com.kyvislabs.api.client.gateway.api.functions.actions.actions.ScriptAction.handleResponse(ScriptAction.java:70)
at com.kyvislabs.api.client.gateway.api.functions.Actions.handleResponse(Actions.java:45)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor._execute(FunctionExecutor.java:146)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor.execute(FunctionExecutor.java:183)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor.run(FunctionExecutor.java:209)
at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:550)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value: '{\r\n "Id": "<id>",\r\n "Status": "OK",\r\n "ProviderName": "<provider>",\r\n "DateTimeUTC": "\\/Date(1754415022008)\\/",\r\n "Items": [\r\n {\r\n "Description": "PUMP, 4\u201d DIP TUBE,
at org.python.core.PyString.(PyString.java:59)
at org.python.core.PyString.(PyString.java:83)
at org.python.core.PyString.(PyString.java:87)
at com.kyvislabs.api.client.gateway.api.functions.actions.actions.ScriptAction.handleResponse(ScriptAction.java:66)
... 11 common frames omitted
This looks like it might be a bug in the kyvislabs ScriptAction script library, that it is unable to parse the unicode character \u201d that was returned from the API call.
This is my YAML function:
getProduct:
url: "{{var::baseUrl}}/Items/{{var::handler.itemId}}"
method: get
responseType: json
actions:
- action: tag
path: "{{var::apiName}}/data/testproduct"
type: jsonExpand
- action: script
project: global
script: dev.logProduct
I have an API GET function where the response contains some characters that are non-ASCII but are UTF-8 characters. Some examples of these characters are: –,¼,½,¾,“,”,Â,â,®. The function works fine when it has only a "tag" action, but when I add a "script" action to the function, I get the following error (with customer data redacted) and the script does not execute.
This looks like it might be a bug in the kyvislabs ScriptAction script library, that it is unable to parse the unicode character \u201d that was returned from the API call.
This is my YAML function: