cancel
Showing results for 
Search instead for 
Did you mean: 

Removing certain fields from API response in API management

0 Kudos

Hello Experts,

I have a requirement to remove certain set of fields from response of an API in SAP API management. Could you please guide how this can be done ?

Regards,

Varun Vichare.

View Entire Topic
MortenWittrock
Active Contributor
0 Kudos

Hi Varun

You have a couple of options for transforming API output in API Management. If the response is XML, you can do an XSLT transformation with the XSL Transform policy (located in the Mediation Policies category). If the response is JSON, you can transform it with the JavaScript policy (located in the Extension Policies category).

Regards,

Morten

0 Kudos

Hi Morten,

Do you have a JavaScript code snippet through which we can remove certain fields from JSON response.

Regards,

Varun Vichare.

MortenWittrock
Active Contributor
0 Kudos

Hi varun_vichare_cpi

There is an example of modifying a JSON response using JavaScript in the blog post SAP API Management – Mash-Up in an API proxy by svenhuberti. Scroll down to section "Add the geocoding information to the backend response". Sven adds elements rather than removing them, but updating the script should be simple enough - and is left as an exercise for the reader i.e. you 🙂

Regards,

Morten