how to access custom attribute from javascript

Not applicable

Hi,

I am new to apigee,I am not able to custom attribute from javascript

in apigee doc it mention

verifyapikey.{policy_name}

what is policy_name?

Is policy_name related to Developer apps product name

I tried this also

created one new policy


<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<VerifyAPIKeyasync="false"continueOnError="false"enabled="true"name="Verify-API-Key">   
<DisplayName>Verify API Key</DisplayName>
<Properties/>
<APIKeyref="request.header.apikey"/>
</VerifyAPIKey>

when i am adding this policy to my flow it breaks my present flow

var customattr1 = context.getVariable("verifyapikey.Verify-API-Key.apiproduct.customattribute1");

Solved Solved
0 4 782
1 ACCEPTED SOLUTION

nmunro
New Member

@Guru Venkatesh,

in apigee doc it mention

verifyapikey.{policy_name}

what is policy_name?

policy_name is the name you give to the verify API key policy.

In your example, the policy_name is "Verify-API-Key"

View solution in original post

4 REPLIES 4

nmunro
New Member

@Guru Venkatesh,

in apigee doc it mention

verifyapikey.{policy_name}

what is policy_name?

policy_name is the name you give to the verify API key policy.

In your example, the policy_name is "Verify-API-Key"

@Guru Venkatesh,

Which policy is it that breaks the flow? What is the error message you receive?

I didn't have any trouble with a basic proxy with your VerifyAPIKey policy (as defined above) and a Javascript policy with only the javascript line you provided and a print statement.

The javascript returned the value of an attribute named customattribute1 that I created on my API product.

Thanks Neil for your reply,its is working now,i created custom attribute in wrong place

i am calling like this in javascript its working

var customattr1 = context.getVariable("verifyapikey.Verify-API-Key.app.customattribute1");

Hello,

 

I am also trying to extract custom attribute from apps page, can't we extract the value in javascript directly instead of using verifyapikey policy?