How to append path value in assign message policy

Hi, 

I am just trying to append one path suffix to other proxy base path for proxy chaining in target endpoint.

I created one assign message policy to set new path suffix and I want to append that in local target connection path like this - /service/v1/data/{apigee.id}.

Here apigee.id is extracted variable

and I don't want to add this (/data/{apigee.id}) directly in target endpoint base path as I am using multiple condition flows and every flow is using different target paths. So, I need to append this path suffix (data/{apigee.id}) by other policy

Kindly please share your suggestions to achieve this

Assign message policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
<DisplayName>Assign Message-1</DisplayName>
<Properties/>
<Set>
<Headers/>
<QueryParams/>
<FormParams/>
<!-- <Verb>GET</Verb> -->
<Path>/data/{apigee.id}</Path>
</Set>
<AssignVariable>
<Name>target.copy.pathsuffix</Name>
<Value>false</Value>
<Ref/>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

 

 

 

Target endpoint:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows/>
<LocalTargetConnection>
<APIProxy>Service</APIProxy>
<ProxyEndpoint>default</ProxyEndpoint>
<Path>/service/v1</Path>
</LocalTargetConnection>
</TargetEndpoint>

Solved Solved
0 2 1,119
2 ACCEPTED SOLUTIONS

Maybe this will help.

First, I don't think there is a graceful way to set the path for a LocalTargetConnection, aside from the Path element. This is the prescribed way:

 

  <LocalTargetConnection>
    <APIProxy>my-inner-proxy</APIProxy>
    <ProxyEndpoint>endpoint1</ProxyEndpoint>
    <!--
         The Path element is interpreted as a Message Template.
         You can rely on variable expansion. 

         Also, if  target.copy.pathsuffix = false (the default),
         Apigee will append  proxy.pathsuffix to the path specified here.
    -->
    <Path>/my-inner-proxy/{variable1}/{variable2}</Path>
  </LocalTargetConnection>

 

To use the Path element, You must know the basepath for the inner proxy, and it should be the left-most segment in the Path element there.

Now, you said

I don't want to add this (/data/{apigee.id}) directly in target endpoint base path as I am using multiple condition flows and every flow is using different target paths. So, I need to append this path suffix (data/{apigee.id}) by other policy

Can you not simply conditionally set a variable named "path-to-append" in your various flows, and then refer to that in the Path element?

 

  <LocalTargetConnection>
    <APIProxy>my-inner-proxy</APIProxy>
    <ProxyEndpoint>endpoint1</ProxyEndpoint>
    <!--
         The Path element is interpreted as a Message Template.
         You can rely on variable expansion. 

         Also, if  target.copy.pathsuffix = false (the default),
         Apigee will append  proxy.pathsuffix to the path specified here.
    -->
    <Path>/my-inner-proxy{path-to-append}</Path>
  </LocalTargetConnection>

 

If you do this, the path-to-append must always have a value, otherwise you will generate a runtime fault.  In your proxy preflow you can set it to (the empty string), using an AssignMessage like this: 

 

<AssignMessage name='AM-Set-Default-Path-to-Append'>
  <AssignVariable>
    <Name>path-to-append</Name>
    <Value></Value>
  </AssignVariable>
</AssignMessage>

 

 

View solution in original post

You need not to do so much things. In proxy chaining as below you can provide the path and it will direct accordingly.

<LocalTargetConnection>
       
<Path>/service/v1/</Path>
</LocalTargetConnection>

View solution in original post

2 REPLIES 2

Maybe this will help.

First, I don't think there is a graceful way to set the path for a LocalTargetConnection, aside from the Path element. This is the prescribed way:

 

  <LocalTargetConnection>
    <APIProxy>my-inner-proxy</APIProxy>
    <ProxyEndpoint>endpoint1</ProxyEndpoint>
    <!--
         The Path element is interpreted as a Message Template.
         You can rely on variable expansion. 

         Also, if  target.copy.pathsuffix = false (the default),
         Apigee will append  proxy.pathsuffix to the path specified here.
    -->
    <Path>/my-inner-proxy/{variable1}/{variable2}</Path>
  </LocalTargetConnection>

 

To use the Path element, You must know the basepath for the inner proxy, and it should be the left-most segment in the Path element there.

Now, you said

I don't want to add this (/data/{apigee.id}) directly in target endpoint base path as I am using multiple condition flows and every flow is using different target paths. So, I need to append this path suffix (data/{apigee.id}) by other policy

Can you not simply conditionally set a variable named "path-to-append" in your various flows, and then refer to that in the Path element?

 

  <LocalTargetConnection>
    <APIProxy>my-inner-proxy</APIProxy>
    <ProxyEndpoint>endpoint1</ProxyEndpoint>
    <!--
         The Path element is interpreted as a Message Template.
         You can rely on variable expansion. 

         Also, if  target.copy.pathsuffix = false (the default),
         Apigee will append  proxy.pathsuffix to the path specified here.
    -->
    <Path>/my-inner-proxy{path-to-append}</Path>
  </LocalTargetConnection>

 

If you do this, the path-to-append must always have a value, otherwise you will generate a runtime fault.  In your proxy preflow you can set it to (the empty string), using an AssignMessage like this: 

 

<AssignMessage name='AM-Set-Default-Path-to-Append'>
  <AssignVariable>
    <Name>path-to-append</Name>
    <Value></Value>
  </AssignVariable>
</AssignMessage>

 

 

You need not to do so much things. In proxy chaining as below you can provide the path and it will direct accordingly.

<LocalTargetConnection>
       
<Path>/service/v1/</Path>
</LocalTargetConnection>