Is there a way to use customized Flow Variable in Transaction Recording Policy ?

In Transaction Recording Policy the "Flow Variable" has a drop down menu (under the 'Transaction Attributes' and 'Custom Attributes' sections) has got three options:

response.status.code

response.reason.phrase

target.ip

However, it does not allow us to use a customized value for Flow Variable. All the other location options such as "Header", "JSON body", "XML body" and "XML and JSON body" allows us to use customized value.

Can you please let me know if there's a way to add customized Flow Variable in Transaction Recording Policy ?

Solved Solved
0 3 299
1 ACCEPTED SOLUTION

Figured out a way to set the customized Flow Variables in Transaction Recording Policy. Using the UI, create a TRP for a product and set the Flow Variable wherever you need with any of the values provided in the drop down menu. Then follow the below steps to replace the standard value for the Flow Variable(s) with any customized value as per your needs:

1. Get the API Product using the below curl command

curl -X GET -H "Content-Type: application/json" -o MyProduct_original.json "https://api.enterprise.apigee.com/v1/organizations/{org-name}/apiproducts/{APIProduct-name}" -u <user>:<password> 

The above command gets the APIProduct information including Transaction Recording Policy (TRP) information and stores it a file "MyProduct_original.json".

2. Copy the file “MyProduct_orignal.json" to another file let's say "MyProduct_modified.json"

3. Edit the file "MyProduct_modified.json" and replace the value of the Flow Variable with an appropriate value.

For ex:

  • Let's say the Flow Variable for "Status" in Transaction Attributes was set to response.status.code. Replace response.status.code with a new value let's say “ee.transaction.monetisable"
  • Similarly edit all the places where you want to set a different value for the Flow Variables.
  • Save the file.

Note: While modifying the JSON output file in Step#3, be careful not to add/remove any backslashes

4. Update the API Product with the modified file "MyProduct_modified.json" using the below curl command

curl -X PUT -H "Content-Type: application/json" -d @MyProduct_modified.json "https://api.enterprise.apigee.com/v1/organizations/{org-name}/apiproducts/{APIProduct-name}" -u <user>:<password>

Here is the screenshot showing the customized Flow Variable after following the above variables:

1388-trp-with-customizedflowvariable.png

View solution in original post

3 REPLIES 3

Hi @AMAR DEVEGOWDA -

As a workaround, try using the Assign Message policy on the response to to populate the header with the variable value.

<Set>    
    <Headers>      
        <Header name="custom_variable_header_name">{custom_variable}</Header>    
    </Headers> 
</Set>

Then you could define your transaction recording policy like this:

1385-custom-variable-in-tx-rec-policy.png

It's not the most graceful solution, but it should work.

Dear @Floyd Jones,

Thanks for your suggestion. We can add the customized variable for Header. But we can't do it for the Flow Variable as it has a drop down menu. I was looking on how to do it for Flow Variable.

Figured out a way to set the customized Flow Variables in Transaction Recording Policy. Using the UI, create a TRP for a product and set the Flow Variable wherever you need with any of the values provided in the drop down menu. Then follow the below steps to replace the standard value for the Flow Variable(s) with any customized value as per your needs:

1. Get the API Product using the below curl command

curl -X GET -H "Content-Type: application/json" -o MyProduct_original.json "https://api.enterprise.apigee.com/v1/organizations/{org-name}/apiproducts/{APIProduct-name}" -u <user>:<password> 

The above command gets the APIProduct information including Transaction Recording Policy (TRP) information and stores it a file "MyProduct_original.json".

2. Copy the file “MyProduct_orignal.json" to another file let's say "MyProduct_modified.json"

3. Edit the file "MyProduct_modified.json" and replace the value of the Flow Variable with an appropriate value.

For ex:

  • Let's say the Flow Variable for "Status" in Transaction Attributes was set to response.status.code. Replace response.status.code with a new value let's say “ee.transaction.monetisable"
  • Similarly edit all the places where you want to set a different value for the Flow Variables.
  • Save the file.

Note: While modifying the JSON output file in Step#3, be careful not to add/remove any backslashes

4. Update the API Product with the modified file "MyProduct_modified.json" using the below curl command

curl -X PUT -H "Content-Type: application/json" -d @MyProduct_modified.json "https://api.enterprise.apigee.com/v1/organizations/{org-name}/apiproducts/{APIProduct-name}" -u <user>:<password>

Here is the screenshot showing the customized Flow Variable after following the above variables:

1388-trp-with-customizedflowvariable.png