Hi All,
I have a usecase where I have 2 or more TargetEnd Points.
In PostMan When I'm sending request as content type = application/json , Then it must hit the target 1.
<?xml version="1.0" encoding="utf-8"?> <Name> <FName>Govind</FName> <Lname>Verma</Lname> <City>Ranchi</City> </Name>
In PostMan When I'm sending request as content type = application/xml , Then it must hit the target 2.
{"Name":{"FName":"Govind","Lname":"Verma","City":"Ranchi"}}
Could someone please help me or any advice?
Thanks and Regards
Govind Verma
@Anil Sagar @ Google, @Dino-at-Google,@Robert Johnson,@Brendan,@Siddharth Barahalikar, @deboraelkin,
Solved! Go to Solution.
Hi @Govind Verma You need a route rule!
Check it out here-> Route rules
Make the condition for the route based on the content type header. Probably you should also make that header required in the proxy preflow and confirm its xml or json.
Feel free to ping back with any clarification needed.
Otherwise, if this answered your question, please accept to close it out.
Hi Govind as said by Robert, the easiest way is to use RouteRules,
https://docs.apigee.com/api-platform/fundamentals/understanding-routes
Let's say, you have two Target endpoints - JSONEndpoint & XMLEndpoint
<RouteRule name="MyRoute"> <Condition>request.header.Content-Type= "application/json"</Condition> <TargetEndpoint>JSONEndpoint</TargetEndpoint> </RouteRule> <RouteRule name="default"> <TargetEndpoint>XMLEndpoint</TargetEndpoint> </RouteRule>
The above route rules will route to XMLEndpoint when the header is anything other than application/json
Hi @Govind Verma You need a route rule!
Check it out here-> Route rules
Make the condition for the route based on the content type header. Probably you should also make that header required in the proxy preflow and confirm its xml or json.
Feel free to ping back with any clarification needed.
Otherwise, if this answered your question, please accept to close it out.
Thanks for your reply @Robert Johnson
Hi @Govind Verma, You can do using route rule with proper condition and multiple target endpoints, another way is to use scripting and decide target dynamically using java script.
Thanks for your reply @Priyadarshi Ajitav Jena
Hi Govind as said by Robert, the easiest way is to use RouteRules,
https://docs.apigee.com/api-platform/fundamentals/understanding-routes
Let's say, you have two Target endpoints - JSONEndpoint & XMLEndpoint
<RouteRule name="MyRoute"> <Condition>request.header.Content-Type= "application/json"</Condition> <TargetEndpoint>JSONEndpoint</TargetEndpoint> </RouteRule> <RouteRule name="default"> <TargetEndpoint>XMLEndpoint</TargetEndpoint> </RouteRule>
The above route rules will route to XMLEndpoint when the header is anything other than application/json
Thanks for your reply @Siddharth Barahalikar