- I have a request coming to API Proxy.
- First I have Assign Message Policy which prepares the Request.
- Then It is intercepted by Service CallOut Policy where it hits the service with above Request and it returns the JSON.
- Then I have Extract Variables Policy which parse the JSON and sets the variables.
- Now I want to send some of these extracted variables to TargetEndPoint
What should be the approach ?
Hi @GAURAV can you upload your proxy here?
Basically it should take an Assign Message policy (in Target Endpoint / Pre-Flow / Request Segment) to do what you describe here.
For eg assuming the extracted variable name is “extracted_variable”:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Set-Target-Endpoint-Query-Parameters">
<DisplayName>Set Target Endpoint Query Parameters</DisplayName>
<Add>
<QueryParams>
<QueryParam name="new_param">{extracted_variable}</QueryParam>
</QueryParams>
</Add>
</AssignMessage>
1 Like
You can use AssignMessage policy in your TargetEndpoint preflow or conditional flow,and use the same extracted variable names.
Hi @Prithpal Bhogill
Thanks. I will try the above solution and let you know the result.
Hi @Prithpal Bhogill
I was able to set the variable in query param as suggested above.
Please do tell how we can set in request header.
Thans
You can use the Headers element to do that:
<Headers>
<Header name="new_header">{extracted_variable}</Header>
</Headers>
Hi @Prithpal Bhogill
How to set this extracted variable in request cookies ?
Thanks
You can take a look at this page in the doc. It has examples of using AssignMessage to set query params, headers, and other parts of a request or response.
Stephen