[Script]Error in groovy script in transport types synchronous and asynchronous
Test cases Instance: insights Tenant: Dovetail Flows:
- ScriptGroovyScriptAWS_Asynchronous
- ScriptGroovyScriptAWS_Queues
- ScriptGroovyScriptAWS_Synchronous
The flow notes contain the url which you can use with Postman to test the working.
These flows are also available in the Regression Tests tenant on development, where they work fine.
The error for the asynchronous and synchronous flow is:
{
"code": 500,
"error": "java.net.URISyntaxException: Illegal character in scheme name at index 0: %7B%22values%22:[%7B%22values%22:[%22ce%22,%22us-east-1%22],%22strings%22:[%22%22,%22.%22,%22.amazonaws.com%22],%22empty%22:false,%22bytes%22:%22Y2UudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20=%22,%22valueCount%22:2%7D],%22strings%22:[%22https://%22,%22%22],%22empty%22:false,%22bytes%22:%22aHR0cHM6Ly9jZS51cy1lYXN0LTEuYW1hem9uYXdzLmNvbQ==%22,%22valueCount%22:1%7D",
"info": "Something went wrong calling the HTTP service. Please refer to the logs for more information."
}
See routes in error message: routes.txt
I looked at the issue. The problem is that the script uses GString objects. That is, Groovy sets up an internal structure of strings. To make it a normal String again, you have to do something like this:
GString host = “${serviceName}.${region}.amazonaws.com” def hostAsString = host.toString()
Or just use string directly:
String host = “${serviceName}.${region}.amazonaws.com”
Last one I applied, and you could test it.
Why it does go well with queues, is because you send it to ActiveMQ the object is automatically converted to a String (the toString() is applied). In local testing, this will also happen, since it should convert the object to String.However, in a synchronous or asynchronous, Camel will not do this (since it remains within Java) and in this case you need to call the .toString() method yourself.Apparently, somewhere a conversion is still applied to the internal structure of GString, causing it to be displayed, instead of the value. I wasn't really able to quite figure out why this was the case, but when I started looking at Groovy's documentation, it was quickly apparent.