cancel
Showing results for 
Search instead for 
Did you mean: 

Status Code for HTTPS Sender Adapter

0 Kudos

Hello People

I have a 3rd party tool accessing CPI iflow via HTTPS sender adapter. They trigger the iflow via a request and receive some response back. Their requirement is to get the Https status code back in case of any error. For a successful processing, they are getting a proper HTTPS status code in the response.

Now i used exception handling for getting the erroneous HTTPS status code, however i am not geting any.

Can anyone please help me with this requirement, if it is possible

yatanveersingh
Active Participant
0 Kudos

can you show your process, did you put the content modifier inside the exception block with the header as http.StatusCode to whatever you want to respond back.

0 Kudos

Hi Yatanveer

The content of statusCode should be dynamic for whatever error is received in the https adapter. For capturing this i used the below groovy script in my exception sub-process:

However i am getting a blank value for 'StatusCode' property.

Regards
Aniket

0 Kudos

This is the code

View Entire Topic
Sriprasadsbhat
Active Contributor
0 Kudos

Hello Aniket,

Below should work for you.

Add exception Subprocess follow below screenshot that would help you to tweak HTTP response code and error response.You can use this as reference and build your error handling as required.

Step 2:

Add groovy script like below to set desired HTTP response code and response.

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


def Message processData(Message message) {
 
    def map = message.getHeaders();
    map.put("Content-Type",   "application/json");
    map.put("CamelHttpResponseCode",   900);
    def props = message.getProperties();
    message.setBody("{\"status\": \"ScriptError\"}");
    return message;
}

Regards,

Sriprasad Shivaram Bhat

Hemant_CG
Explorer

Hello Sri,

It only works if you set End Message instead of Error end in exception sub-process but that marks the message completed in CPI. if you set Error end, then sender gets the generic 500 error with MPL ID. Is there a way to send this custom response while making message status failed in CPI.

Thanks,

Hemant