cancel
Showing results for 
Search instead for 
Did you mean: 

OData Adapter Scrambles JSON result

MultivacTest123
Explorer
0 Kudos

inkedafter-adapter-1.jpgHi Experts,
for the past days i am trying to call a OData Service and save the Result as a csv, but in vain.
It sounds easy but the OData call scrambles the results so im forced to read the XML answer with a groovy script to order the result in the way i need it. I tried it with XMLSlurper and XMLParser but also without success, because i dont get any Data when i try to call the node in the xml via:
def body = message.getBody()

def list = new XmlSlurper().parseText(body)

def result = list.nodeA.nodeB[0].bukrs //null Result

After that i tried to get a JSON result from the OData Adapter, but also with no sucess. As u can see in the Image, the OData call has (i dont know why..) 4 Steps. 2 Before and 2 after the Adapter. And 1 of those Steps is actually the JSON i need(also in the right order!!), but within the same Adapter the next step makes it into a sudo xml with seemingly random order. Can anybody help me with either getting the JSON i need from the OData Adapter, or even better the correct XML which the OData Adapter should give back. I should mention the OData Call works perfectly fine and in the right order when tested with the SAP Gateway Client. (Also the Message Content only gets shown every second time i reload the page... but thatinkedafter-adapter-2.jpg just seems like a bad frontend)

Ryan-Crosby
Active Contributor

Your response is in JSON so you would need to use the JSONSlurper, or you would need to ensure the OData service returns the payload in XML if you use the XMLSlurper.

Accepted Solutions (0)

Answers (2)

Answers (2)

vuyyurujyothi
Participant
0 Kudos

Hi,

Did you resolve this? I am also getting same issue.

Thanks,

Jyo

TheoExall
Explorer
0 Kudos

Try changing:

def body = message.getBody()

def list = new XmlSlurper().parseText(body)

to:

def list = new XmlParser().parse(message.getBody(java.io.Reader))


Just make sure your payload at the script step is actually XML, from your screenshots and explanation it's not clear if you are using XML or JSON