Hi,
I have configured a csutom picker field for data from ServiceNow, but on loading options I get following error:
Error searching: java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
at org.codehaus.groovy.runtime.ConvertedMap.invokeCustom(ConvertedMap.java:52)
at org.codehaus.groovy.runtime.ConversionHandler.invoke(ConversionHandler.java:113)
at jdk.proxy1/jdk.proxy1.$Proxy5118.isEmpty(Unknown Source)
My code for the field is:
HTTPBuilder getHttpBuilder() {
)
}
search = {
HttpBuilder.request(Method.GET, ContentType.JSON) {
headers.Accecpt = 'application/json'
headers."x-sn-apikey" = "<TOKEN>"
uri.path = "/api/now/v2/table/cmdb_ci_service_business"
uri.query = [fields: 'sys_id, name']
}
}
toOption = { Map<String, String> map, Closure<String> highlight ->
new PickerOption(
value: map.sys_id,
label: map.name,
html: highlight(map.sys_id, false)
)
}
Any idea, why the json object can not be converted to a map?
If I create a separate output for the http request, all data are available:
def output = HttpBuilder.request(Method.GET, ContentType.JSON) {
headers.Accecpt = 'application/json'
headers."x-sn-apikey" = "<TOKEN>"
uri.path = "/api/now/v2/table/cmdb_ci_service_business"
uri.query = [fields: 'sys_id, name']
response.failure = { null }
}
def bsNumber = output["result"]*."number"
def bsName = output["result"]*."name"
def bsSys = output["result"]*."sys_id"
log.info(bsNumber)
log.info(bsName)
log.info(bsSys)