SpagoBI DataSet REST Webservice via Groovy
SpagoBI DataSet REST Webservice via Groovy
UPDATE: THIS IS A GREAT IDEA, EXCEPT IT DOESN’T WORK IN THE FINAL STEP. Per SpagoBI Support, Groovy cannot be used in a script-based Dataset to provide rows of data. According to the last support ticket, there is no intent to make that work. |
Groovy Data Set to make RESTful web service call and return IP Address related information in SpagoBI’s XML format
Prerequisites :
- Upgrade Groovy in SpagoBI and Drop in a copy of the WSLite library
- Restart SpagoBI
Create a new SpagoBI Data Set
For the Type, Specify Script
For the Script Language, Specify Groovy
Create a parameter : param_ip, of the type Generic
View the code section below and copy/paste that into your Script section.
Groovy code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import wslite.rest.* def param_ip = parameters['param_ip'] ?: '' def client = new RESTClient("http://ip-api.com/json/${param_ip.toString()}") def response = client.get() assert response.statusCode == 200 def str = response.json """ """.toString() |
Press the Save Button
Next…
Now, Switch to the Preview tab
Enter a Domain or IP address and press the Submit/OK button