Make sure that you have Manage API or Activate or Deactivate API's
functional privilege. If you are an Administrator, you must have this privilege by default.
About this task
You want to display a custom message based on the response, depending on the value of the
X-Api-Provider-Secret header.
- Open the menu options and select APIs.
- Open e-commerce API. For example, ConsumerAPI.
- Click Edit to Response Transformation policy to the Consumer API.
- Select Policies > Response Processing > Response
Transformation.
The Response Transformation policy properties section
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.
- Provide the following information
- Variable: ${request.headers.X-API-Provider-Secret}
- Operator: Equals
- Value: Accepted
- Click Add.
The condition checks the value of the
X-Api-Provider-Secret header to determine the appropriate transformation. In this case,
Accepted.
- Select Transformation Configuration > Status transformation.
The Status transformation policy properties section appears.
- Provide the following information
- Code: ${response.status.Code}
- Message: Request has been processed successfully
- Click Save.
webMethods API Gateway checks the value of the X-Api-Provider-Secret header to determine the
appropriate transformation. If the header value is Accepted, the response status
message is modified to indicate that the request is processed successfully.
Now that you created a e-commerce REST API and implemented the request and response
transformation policies, make sure that the applied policies work as expected by using API testing
tools. For details about how to test the API, see Testing request and response transformation policies.