Use the Request Transformation policy to modify the contents of an incoming request such
as headers, payload, query parameters, path parameters, HTTP method using the configurations given
by the API Provider.
About this task
The request transformation workflow is as follows:
- The API Provider configures the Request Transformation policy in the Request Processing stage of
webMethods API Gateway. The API provider configures the details about when and how to transform the contents of
an incoming request.
- The client sends the request to webMethods API Gateway.
- webMethods API Gateway applies the transformations configured by the API Provider and transforms the
incoming request.
- webMethods API Gateway sends the transformed request to the native API.
- Native API processes the transformed request and sends the response to webMethods API Gateway.
- webMethods API Gateway forwards the response to the
client.
Consider a scenario where you have a legacy REST API (employeeApi) that does not adhere to the
REST API standards. For example, it accepts functional information such as employee name through a
header employeeName
instead of accepting them through query or path parameters and
you want to modify the API to REST standards.
- Open the menu options and select APIs.
A list of
available APIs appears.
- Select a Rest API from the list of APIs and click
Edit.
- Select . The Request Transformation details
page appears.
- In the Condition section, select OR. The
configured transformation is applied when at least one of the conditions is satisfied.
Note: The condition can also be set to AND operator. The configured transformation is applied only
when all the set conditions are satisfied.
- Click Add Condition to configure the conditions to evaluate the
contents on the request.
- Specify the Variable. Example, Content-Type.
- Specify the perator to use to relate variable and the value provided. Example,
Equals.
- Specify the value. Example, application/json. When you select the operator Equals, the
Condition checks if the variable Content-Type is equal to the value
application/json.
- Click Add.
- Select . The Header/Query/Path transformation
details page appears.
- In Add/Modify section, add the variable and set its value. Here,
native API accepts employee name through header
${request.headers.employeeName}
and
you want the native API to accept these values through the query parameter
${request.query.name}
and expose this change to the client without exposing the
query parameter.
To achieve this, set the variable and the value parameters as follows:
- Variable:
${request.headers.employeeName}
- Value:
${request.query.name}
- Click Add.
- In the Remove section, add
${request.query.name}
to
remove the query parameter from the request so that it does not reach the native API.
- Click Save.
This request transformation policy
configuration allows the native API to accept the header values through query parameters. The native
API accepts the header values through the query parameters by transforming the query parameters to
header parameters and then removing the query parameter from the incoming request.