How do I transform a request and its response using Transformation Policy?
About this task
Use the Response Transformation policy to modify the contents of an outgoing response such as headers, payload, query parameters, path parameters, HTTP method using the configurations given by the API Provider.
The response transformation workflow is as follows:
- The API Provider configures the Response Transformation policy in the Response Processing stage of API Gateway. The API provider configures the details about when and how to transform contents of an outgoing response.
- The client sends the request to API Gateway.
- API Gateway forwards the request to native API.
- Native API processes the request and sends response to API Gateway.
- API Gateway applies the transformations configured by the API Provider and transforms the outgoing response.
- API Gateway forwards the transformed response to the client.

Consider a scenario, where a native API URL is moved permanently or temporarily, the native API sends a 301 or 302 status code, and also sends the new address in the location header. However, when API Gateway comes across the 301 or 302 status code, API Gateway reads the status code and the location header, and redirects the request to new address mentioned in the location header. API Gateway, then sends the response from the new address to the client. This is how 3xx status code is handled in API Gateway.
In this scenario, if you do not want API Gateway to do the redirection, instead you want the clients to receive the 3xx status code, and then do the redirection. This can be achieved by using the Status Transformation policy in the Response Processing stage.
To achieve this transformation: