Proxy Chaining: APIProxy field

Hi,

I'm chaining API proxies together . For this, I followed apigee doc https://docs.apigee.com/api-platform/fundamentals/connecting-proxies-other-proxies 

I've noticed that when I set the element 'APIProxy' with a constant value (ex: prov-dgt-dataflow-management-v1), both API Proxies are able to communicate.

However, if I set the element 'APIProxy' with the content of a variable (ex: ${my.var.api.proxy} , both proxies are not able to communicate. The messages don't even arrive to the second API Proxy.

Despite of using the same URL (or curl command).

Is it possible to use a variable to set the element 'APIProxy'? 

Is there the same limitation for the element 'Path' ?

Thanks,

Solved Solved
0 4 168
1 ACCEPTED SOLUTION

Thanks Raven! Good catch!

View solution in original post

4 REPLIES 4

Neither the APIProxy element nor the Path element within LocalTargetConnection accept a "message template" , which is the thing that would allow you to refer to something like {my.var.api.proxy} . 

After Raven's post, I looked further, and need to correct my post! 

You can do this:

 

<TargetEndpoint name="target-1">
  ...
  <LocalTargetConnection>
     <!-- the following will work -->
     <APIProxy>{variable-reference-here}</APIProxy> 
     <ProxyEndpoint>endpoint1</ProxyEndpoint>
  </LocalTargetConnection>
</TargetEndpoint>

 

Note, there is no preceding dollar-sign in that variable reference. It's just curly braces. 

I think you cannot do this: 

 

<TargetEndpoint name="target-1">
    ...
    <LocalTargetConnection>
        <!-- The following won't work -->
        <Path>{variable-reference-here}</Path> 
    </LocalTargetConnection>
</TargetEndpoint>

 

I can see, that might  be a nice feature to have.  But it's not possible today.

Hey Dino, first time I've ever said this, but I'm receiving different results from your post. Variable references are failing for the <Path> method as you described, but they are working for me using the <ProxyEndpoint> method.

In my Target Endpoint preflow I have the following AssignMessage policy:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="DefineApiProxy">
  <DisplayName>DefineApiProxy</DisplayName>
  <AssignVariable>
    <Name>next-proxy-chain</Name>
    <Value>proxy-chain-b</Value>
  </AssignVariable>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
  <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

And then my TargetEndpoint looks like this:

<TargetEndpoint name="target-1">
  ...
  <LocalTargetConnection>
    <APIProxy>{next-proxy-chain}</APIProxy>
    <ProxyEndpoint>default</ProxyEndpoint>
  </LocalTargetConnection>
</TargetEndpoint>

It's odd that variable reference doesn't work for <Path>, though. I agree that this would be a nice feature to have in the future. 

Thanks Raven! Good catch!

Muchas gracias!!