Hi Team,
I have a usecase where I have more than one TargetEndPoints.
In PostMan When I'm sending request body as json ,
My Request is:
{"Detail":{"Name":"Rishika","Age":"24","City":"Delhi"}}
Then it must Hit my target 1 :
When my Request as Xml :
<?xml version="1.0" encoding="UTF-8"?> <root> <Detail><Age>24</Age><City>Delhi</City><Name>Rishika</Name></Detail></root>
Then it must Hit my target 2 :
http://www.mocky.io/v2/5ca1e83a370000640089951c
When my request is other than Xml or Json then it hits :
http://www.mocky.io/v2/5ca1e8893700005900899521
My RouteRule Condition is as:
<RouteRule name="MyRoute">
<Condition>request.body = "application/json"</Condition>
<TargetEndpoint>ApigeeJson</TargetEndpoint>
</RouteRule>
<RouteRule name="MyRoute1">
<Condition>request.body = "application/xml"</Condition>
<TargetEndpoint>ApigeeXml</TargetEndpoint>
</RouteRule>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
Any Advice what's wrong here?
Thanks
Rishika
Solved! Go to Solution.
You need to use Headers.
When using Body, you also add appropriate headers either using Content-type or Accept. Use them in your condition,
<Condition>request.header.Content-type = "application/json"</Condition> or <Condition>request.header.Accept = "application/json"</Condition>
You need to use Headers.
When using Body, you also add appropriate headers either using Content-type or Accept. Use them in your condition,
<Condition>request.header.Content-type = "application/json"</Condition> or <Condition>request.header.Accept = "application/json"</Condition>
Hi Siddharth,
Is there any way to route a request by help of request body?
We do not have a request.body flow variable in Apigee.
https://docs.apigee.com/api-platform/reference/variables-reference#request