How to pass the variable from API proxy to Shared Flow

Hi Team,

We need to pass a variable from API proxy to Shared flow.

1. We used assign to store the variable.

<AssignVariable>

<Name>flow.xyz.ABCD</Name>

<value>'Hello'</value>

</AssignVariable>

8231-assign-the-value.jpg

2. We pass the variable in Paraneter in the Flow Callout as mentioned below:

<Parameter name="ApigeeTransactionID">{flow.xyz.ABCD}</Parameter>

8232-parameter-pass-to-shared-flow.jpg

3. In the shared flow, we are using the variable passed from the API proxy to Shared flow

8233-using-the-variable-in-shared-flowjpg.jpg

0 2 1,772
2 REPLIES 2

Hi @Amit Vij,

Variables assigned in your proxy flow will be available to the shared flow. In your example, `messageid` will be available without having to pass it as a separate value. Similarly for `flow.xyz.ABCD`. You can also pass parameters as you've shown.

However, there are a few errors in your policies:

  1. To set a variable from another variable in Assign Message, use the <Ref> element.
  2. If you want to combine a variable with other text, you use the <Template> element.
  3. In your RaiseFault message you are not properly referencing `flow.xyz.ABCD`, missing the initial '@' prefix.
  4. FYI, in your RaiseFault message you no longer need the prefixes '@' and suffix '#', you can just use the variables inclosed in curly braces.

See docs and examples for more details here: https://docs.apigee.com/api-platform/reference/policies/assign-message-policy#assignvariable

Hope that helps!

Kurt is correct, AND, there is also a mechanism to set variables just for the scope of the SharedFlow.

<FlowCallout name="String-Handler">
  <DisplayName>String Handler</DisplayName>
  <Parameters>
    <Parameter name="input">this is a message template {system.time}</Parameter>
    <Parameter name="operations">concatenate tolowercase</Parameter>
    <Parameter name="outputVariable">string.handler.output</Parameter>
  </Parameters>
  <SharedFlowBundle>StringHandler</SharedFlowBundle>
</FlowCallout>

See the reference documentation for FlowCallout, specifically for the Parameters element, for more information.