Scenario: While sending the request, Client sends the search parameter in the form of query but Back-end system excepts it as a header parameter
Sample Request:
<API Proxy URL>?search=Sydney
Steps:
1. Add an instance of Assign Message in Request Path.
2. Modify the policy as per requirement.
In this case, the request is modified as below.
A new header with name 'find' is created using Set operation.
Query Parameter 'search' is deleted using Remove operation.
Code:
<!-- This policy can be used to create or modify the standard HTTP request and response messages -->
<AssignMessage async="false" continueOnError="false" enabled="true" xmlns='http://www.sap.com/apimgmt'>
<!-- Sets a new value to the existing parameter -->
<Set>
<Headers>
<Header name="find">{request.queryparam.search}</Header>
</Headers>
</Set>
<Remove>
<QueryParams>
<QueryParam name="search"></QueryParam>
</QueryParams>
</Remove>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<AssignTo createNew="false" type="request">request</AssignTo>
</AssignMessage>
No comments:
Post a Comment