Using flow variables in the Path of LocalTargetConnection of a Target Endpoint

Not applicable

Hi,

I'm trying to implement a local proxy-chaining mechanism between my Proxy API's. To do so I wrote a JS policy that resolves the new path and sets it to a new variable:

context.setVariable("routePath",routePath);

then I set a RouteRule in the proxy's request pre-flow:

    <RouteRule name="re-route">
        <Condition>request.header.re-route is true</Condition>
        <TargetEndpoint>re-route</TargetEndpoint>
    </RouteRule>

and my Target endpoint is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="re-route">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <Flows/>
    <LocalTargetConnection>
        <Path>{routePath}</Path>
    </LocalTargetConnection>
</TargetEndpoint>

The thing is, when I try to use routePath variable inside the LocalTargetConnection's Path I get a deployment error from Apigee.

Why can't Apigee evaluate my variable and re-route the request accordingly? Am I missing something?

1 2 829
2 REPLIES 2

Not applicable

It depends on where you have kept javascript policy and from where you try to access them.

As per the document when we try to access a variable which is out of scope, we shouldn't get deployment error.

It's important to note that if you try to access a flow variable that is out of scope, you will receive a NULL value. If you try to set a flow variable before it is in scope, the proxy does nothing; it does not generate an error and does not set the variable.

However you can use assign variable to solve the same thing .

<AssignMessage name="Assign-Message-1">
  <AssignVariable>
    <Name>appSecretGet</Name>
    <Ref>appSecretSet</Ref>
    <Value>0</Value>
  </AssignVariable>
</AssignMessage>


Hope this answer helps

Hi @RoyVaknin, did you ever get around this issue, I am facing it right now!