cancel
Showing results for 
Search instead for 
Did you mean: 

Read data of Request Reply

former_member700134
Discoverer
0 Kudos

Hi there, I'm new in SAP CPI. I'm using a Request Reply to connect to facebook and return some data. This works fine. My issue is how to read this data in my next step, a Groovy script. I can't find it. Thanks a lot.

Accepted Solutions (1)

Accepted Solutions (1)

former_member235395
Contributor
0 Kudos

Hi Claudio,

Remember that, the message goes through every step of the whole Iflow, from sender to Receiver. In Groovy Script Step case, before Groovy Script Step, you will have the body message, if you want to read this "Message Body", you will have to capture the message body using:

def body = message.getBody(java.lang.String) as String; (Use "def" sentences to define a variable)

Check this example:

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

import java.util.HashMap;

def Message processData(Message message) {

def body = message.getBody(java.lang.String) as String;

def messageLog = messageLogFactory.getMessageLog(message);

if(messageLog != null){

messageLog.setStringProperty("Logging#1", "Printing Payload As Attachment") messageLog.addAttachmentAsString("ResponsePayload:", body, "text/plain");

}

return message;

}

Regards,

former_member700134
Discoverer
0 Kudos

Hi David. Thanks a lot. Trying this right now!

Best Regards,

Answers (1)

Answers (1)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Claudio,

Good that you are able to get data from Facebook.What data your target system requires and what is your end goal after getting the data from Facebook.Based on this you can decide what steps needs to be used.

Regards,

Sriprasad Shivaram Bhat

former_member700134
Discoverer
0 Kudos

I'm studying and trying to work with this data. Thanks a lot!!