cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch the attachment in sap cpi

vineetha12
Participant
0 Kudos
2,108

Hi EveryOne,

I have an iflow, when there is an exception it is handled via the exception subprocess and the error details are generated as attachments as shown below.

Now I have to send a mail regarding the error details.

My requirement is

1. Can I fetch the attachment named "ODataV2_Adapter_Response_Body" in my iflow ? If yes, please provide a solution for this.

2. In the attachment "ODataV2_Adapter_Response_Body" I have to use a particular field and send that to mail.

for example:

the above image contains the payload of the "ODataV2_Adapter_Response_Body" attachment. I need to fetch the field called "value" located in the "error/code/message" node. Is it possible to fetch this value? please provide a solution for the above requirement.

Thank You,

Vineetha.

Accepted Solutions (1)

Accepted Solutions (1)

PriyankaChak
SAP Champion
SAP Champion
0 Kudos

Hi Vineetha,

1st use groovy script to get the response body in exception sub process block.

Then you can parse the json and send it.

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

import groovy.json.JsonSlurper;

def Message processData(Message message) {

def map = message.getProperties();

def ex = map.get("CamelExceptionCaught");

if (ex!=null) {

if (ex.getClass().getCanonicalName().equals("com.sap.gateway.core.ip.component.odata.exception.OsciException")) {

def resp = message.getBody(String);

def json = new JsonSlurper().parseText(resp);

def value = json.error.message.value;

message.setProperty("errorVal", value);

}

}

return message;

}

Then you access that errorVal property in email body using expression ${property.errorVal}

Regards,

Priyanka

vineetha12
Participant
0 Kudos

Hi Priyanka,

Thanks for the reply! It's working.

Thank You,

Vineetha.

Answers (0)