How do I route to different Target Endpoints based on a value in the URI?

Not applicable

I'm building out a prototype just to begin learning. Here's my scenario:

I am using the StackExchange V2.2 API. Specifically, the SiteInfo method. Here's a couple samples of the API (no auth required):

https://api.stackexchange.com/2.2/info?site=progra...

https://api.stackexchange.com/2.2/info?site=stacko...

What I'd like to do is have my facade be simply /stackexchange/siteinfo/stackoverflow and hit the entire 2.2 API there.

I'm having trouble simply using Route Rules, as they seem to only support exact names, rather than variable extraction.

How might I accomplish this?

0 3 1,281
3 REPLIES 3

you can use ExtractVariables to extract the Path for eg, /stackexchange/siteinfo/{siteid},

then you can use 'siteid' in your condition like this,

<RouteRule>

<Condition> siteid = 'stackoverflow'</Condition>

<TargetEndpoint>stackoverflow</TargetEndpoint>

</RouteRule>

BUT,

you do not need to do this for your usecase, you just need to add a query param to the same target endpoint. basically you just need AssignMessage policy to add queryparam 'site' the value of which is 'siteid' before sending the request to the target

Thanks, this make sense. How would I use an assignmessage policy to add a query parameter? I am not able to find that in the documentation (only for BaaS, not simple APIs): http://apigee.com/docs/search/gss/query%20paramete...