Message Template errors on unresolved variable

Huw
Bronze 4
Bronze 4

Does anybody know if this is a bug with Apigee or a mistake in the documentation?

The docs say:

"Enclose variable names in curly braces { }. If the variable does not exist, an empty string is returned in the output"

source: https://cloud.google.com/apigee/docs/api-platform/reference/message-template-intro#use-curly-braces-...

However, the following throws an error (FCVariableResolutionFailed)

 

<FlowCallout name="FlowCallout-MySharedFlow">
    <Parameters>
        <Parameter name="into.my-shared-flow.param1">{a.variable-that-does-not-exist}</Parameter>
    </Parameters>
    <SharedFlowBundle>my-shared-flow-v0</SharedFlowBundle>
</FlowCallout>

 

Solved Solved
1 3 316
1 ACCEPTED SOLUTION

Same issue, it seems <IgnoreUnresolvedVariables> has no effect with FlowCallout.

It seems the best solution is to use the firstnonnull message template function:

 

 

<FlowCallout name="FlowCallout-MySharedFlow">
    <Parameters>
        <Parameter name="into.my-shared-flow.param1">{firstnonnull(a.variable-that-does-not-exist,)}</Parameter>
    </Parameters>
    <SharedFlowBundle>my-shared-flow-v0</SharedFlowBundle>
</FlowCallout>

 

View solution in original post

3 REPLIES 3

It seems like that IS a documentation bug.

Try including IgnoreUnresolvedVariables in the policy. 

<FlowCallout name="FlowCallout-MySharedFlow">
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <Parameters>
        <Parameter name="into.my-shared-flow.param1">{a.variable-that-does-not-exist}</Parameter>
    </Parameters>
    <SharedFlowBundle>my-shared-flow-v0</SharedFlowBundle>
</FlowCallout>

 

Same issue, it seems <IgnoreUnresolvedVariables> has no effect with FlowCallout.

It seems the best solution is to use the firstnonnull message template function:

 

 

<FlowCallout name="FlowCallout-MySharedFlow">
    <Parameters>
        <Parameter name="into.my-shared-flow.param1">{firstnonnull(a.variable-that-does-not-exist,)}</Parameter>
    </Parameters>
    <SharedFlowBundle>my-shared-flow-v0</SharedFlowBundle>
</FlowCallout>

 

Thanks for contributing that suggestion!