Hi, My requirement is to create a new general purpose API proxy that will dynamically set the target URL and therefore capable of forwarding payloads to different URLs of the same or different origin systems.
Authentication: OAuth
Target endpoint: dynamic, grammatically obtained from “s_url” from within the payload.
@neha , Welcome to Apigee Community. You can able to achieve same using route rules. Did you get a chance to play with same ? Additionally, You can also use javascript to change target url dynamically. Find more regarding same here.
You can use Extract Variable policy to extract the value of the ‘s_url’ tag from within the request payload.
Once this is done, you can use the Assign Message policy or a Javascript to set this value to the ‘target.url’ variable. Make sure that this is done in the Target Endpoint as this variable’s scope is restricted.
The Value element is used to set a specific value. The text of the Value element is not interpreted as a Message Template. (Wrapping variable names in curlies inside the Value element… does nothing! Though there is an outstanding feature request to allow something like this. (** See below for an update on this))
Be aware: Writing the target.url is effective only when executed in the request flow of the target endpoint.
EDIT 2021 July - There has been, for some time now, an additional option within the AssignVariable element, to allow message templates. It is the Template element. it’s pretty simple to use. It looks like this:
<AssignMessage name="Assign-Message-1">
<AssignVariable>
<Name>target.url</Name>
<!-- <Value>{apigee.eventName}</Value> does nothing -->
<Template>{foo} fixed text {bar}</Template>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</AssignMessage>