cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy Script error parsing json payload in CPI

0 Kudos

Hello Experts,

I need to extract fields from json payload using script, but when executing the script i getting below issue.

Error Details java.lang.NoSuchMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getvalues() is applicable for argument types: (com.sap.gateway.ip.core.customdev.processor.MessageImpl) values: [com.sap.gateway.ip.core.customdev.processor.MessageImpl@b8cb74c] Possible solutions: getClass()

Below is the Groovy

Please help me.

Regards,Rajesh

Accepted Solutions (0)

Answers (1)

Answers (1)

MortenWittrock
Active Contributor
0 Kudos

Hi Rajesh

A couple of notes.

First off, have you possibly filled out the Script Function field with the value "getvalues"? If so, that's what your function should be called. Right now it's called processData (the default value). The Script Function field is this one:

Second, you need to import the Message class, for your script to work:

import com.sap.gateway.ip.core.customdev.util.Message

Third, when parsing the JSON body with JsonSlurper, you probably need to explicitly state that you want the message body returned as a String:

def body = message.getBody(java.lang.String)
def slurper = new JsonSlurper().parseText(body)

Let me know how it works out.

Regards,

Morten