JIRA: PLAT-4843
Overview
You can apply transformations the requests and responses in your Proxy APIs through the API Policies tab. Request and response transformation enables you modify the contents of your APIs using key/value pairs in the following ways:
- Request transformation: use this policy to transform a header, body, or the query string in the upstream request before the API user consumes it.
- Response transformation: use this policy to transform a header or JSON content in the API response.
Supported Operation Types
Add
Append
Remove content
Rename an existing content
Replace
Order of Operations
The following table lists the order of operations for requests and response transformations:
Order | Request Transformer | Response Transformer |
---|---|---|
1 | Remove | Remove |
2 | Rename | Replace |
3 | Replace | Add |
4 | Add | Append |
5 | Append | N/A |
Limitations
You cannot apply transformations to the Authorization header.
Transform Requests
You can transform contents in the API requests for the following situations:
- To hide sensitive information in the URL from the API consumer
- To simplify a part of the Proxy query string for usability
- To clarify the purpose or nature of the APIs bundled in the Proxy
Because the transformation of the request occurs upstream, you cannot view the transformed contents in the Developer Portal or API Manager.
Transform Responses
You can transform contents in the API responses for the following situations:
- To add parameters for clarifying information.
- To expose the original query string to the consumer.
- To rename or replace contents not intended to be viewed by the API consumer.
Examples
The following image shows the Response Transformer being set to add the content-type key totalNumbers to the header:
The following image shows the content-type key totalNumbers added to the Response Header after the Proxy is executed in the Developer Portal via the Try it functionality.