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 :

  1. Upgrade Groovy in SpagoBI and Drop in a copy of the WSLite library
    1. See Upgrading Groovy in SpagoBI
    2. See SpagoBI DataSet SOAP Webservice via Groovy
  2. Restart SpagoBI

Create a new SpagoBI Data Set

DS-tab1

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.

DS-tab2-rev2

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

ds-tab5a ds-tab5b

Leave a Reply

Your email address will not be published. Required fields are marked *