SAP BTP Small Talk: Changing the HTTP Response Code within an iFlow

In this short SAP BTP Small Talk note, I’d like to demonstrate how a developer can change the HTTP response code of an integration flow from within the iFlow itself, without applying any API policies.

Scenario

Let’s say you have an iFlow and a proxy that triggers this iFlow.

Creating an API for iFlow: A Step-by-Step Guide
This guide aims to outline the steps required to create an API for iFlow and subsequently run the iFlow through the API. Step # 1. Develop an iFlow Begin by creating a simple iFlow. Deploy any changes made. Step # 2. Setting Up API Providers Navigate to the API section on the

According to one of the business requirements, you need to change the HTTP response code of the API to a non-standard value. To achieve this, you can either implement the corresponding policies for the API or implement the logic directly within the integration flow. Below is a description of how the latter can be done.

Implementation

To return a custom HTTP response code, the developer needs to overwrite the value of the CamelHttpResponseCode header parameter.

See Headers and Exchange Properties Provided by the Integration Framework

This can be done by adding a Content Modifier step to the iFlow. In the Message Header tab, create a header parameter named CamelHttpResponseCode and assign it the desired HTTP status code value.

Testing

In the video fragment below, I trigger the proxy that calls the iFlow, manipulating the value of a custom header parameter, which in turn affects the behavior of the iFlow.

0:00
/0:11

👨‍💻
The SAP BTP Small Talk category consists of short posts that briefly describe solutions or approaches to resolving common issues.