Manipulating the API's Response

This note delves into the capabilities of an essential API Management engine that empowers developers to extend their API's functionality. Specifically, it focuses on policies. I may explore the most commonly used policies in future posts.

See Policy Types


Imagine you need to append specific values to the response header received from the server that manages your API calls. To demonstrate this process, we'll use an API configuration that sends requests to a basic oData service hosted on the SAP system.


The task is to add two custom values to the server's response header.


To accomplish this, we'll employ a JavaScript policy for our API's outgoing response stream.

See Java Script

See Java Script Object Model

Next, add the script to the API policy. Please refer to the video segment below:


For the newly created policy, add a couple of lines of JavaScript. Here's an example:


To validate the implemented policy, you can use the well-known Postman client. Upon completing the request, navigate to the 'Headers' tab. Two new header values should appear in the client application's 'Headers' section.

To deactivate the implemented policy, set the 'enabled' option of the recently added policy to 'false'.

Deploy the changes and trigger the API's endpoint again.

Previously added custom headers should now be removed.

Read more