Andrew Braithwaite
Andrew Braithwaite

Reputation: 111

Apigee: Using environment name to extract variable

I have set up a custom variable in my developer app called sandbox.app_id so I can have different ids for different applications.

I am using the verify api key policy and this populate the verifyapikey.* variables.

I want an ExtractVariable policy similar to below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-TLRG-App-ID">
    <DisplayName>Extract TLRG App ID</DisplayName>
    <FaultRules/>
    <Properties/>
    <Variable name="app_id">verifyapikey.verify-api-key.{environment.name}.app_id</Variable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <VariablePrefix>apigee</VariablePrefix>
</ExtractVariables>

Is this possible, or will I have to resort to javascript?

Upvotes: 0

Views: 610

Answers (1)

Santanu Dey
Santanu Dey

Reputation: 2978

Basically you are trying to access custom application attributes from your extract variable policy. So you need to place this extract variable policy after your verify api key policy. A verify api key policy would load all the application attributes as flow variables for a valid key. You may not see the custom attributes as variables in the debug view. However correct way to access the variables is to use this naming format below:

verifyapikey.{your_policy_name}.app.{custom_attribute_name}

Note that the verify api key policy is mandatory, otherwise the application associated with the API call can not be identified.

Upvotes: 1

Related Questions