Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

AssignMessage : substring not working

hello, I have the below policy which is accessing a variable. I am trying to use the substring function in the policy to take the first 5 charters of the string and forward it in the header. For whatever reason substring seems to be doing nothing. Any ideas on why this is? to lower works just fine, but I can't seem to figure out substring. Thanks.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><AssignMessage async="false" continueOnError="false" enabled="true" name="forward-user-info">
<DisplayName>forward-user-info</DisplayName>
<Set>
<Headers>
<Header name="x-app-name">{substring(dev.app-name,0,4)}</Header>
</Headers>
</Set>
</AssignMessage>
Solved Solved
0 14 1,628
1 ACCEPTED SOLUTION

Try it with IgnoreUnresolvedVariables = true.

<AssignMessage name='AM-Substring'>
  <DisplayName>AM-Substring</DisplayName>


  <!-- this element is important because Apigee attempts to
       treat the 0 and 4 as variables, which will be unresolved.
       :(


       But we just want them to be numbers.
       -->


  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>


  <AssignVariable>
    <Name>assigned</Name>
    <Template>{substring(alphabet,0,4)}</Template>
  </AssignVariable>


</AssignMessage>


View solution in original post

14 REPLIES 14