Unable to retrieve the variable for condition

Hi,

I have defined a variable in a javascript, but while getting that variable in the next policy and comparing it, it is giving wrong result.

I have set a variable named extractvar in java script which is the first policy in my apiproxy. the next policy is validate apikey which has to be run/skipped w.r.t. this variable "extractvar".

But in trace when check, I can see two variable with the same name, but the second one is with a curly bracket at the end.

extractvar

extractvar}

And the validate apikey policy is checking the second variable and giving a wrong result.

condition in proxy--

<Step>

<Name>VerifyAPIKey</Name>

<Condition>{extractvar}=0</Condition>

</Step>

tracing result---

expression (apikeyvalue} equals 0)

expressionResult false

Can someone tell me why this second variable is coming.

Solved Solved
0 7 470
1 ACCEPTED SOLUTION

Hi @krushna.padhee.ap,

The variable need not be enclosed with braces {variable_name} in <Condition> Tag while defining the step.

The following should work. Hope this helps, thank you!

<Step>
<Name>VerifyAPIKey</Name>
<Condition>extractvar = 0</Condition>
</Step>

View solution in original post

7 REPLIES 7

Hi @krushna.padhee.ap,

The variable need not be enclosed with braces {variable_name} in <Condition> Tag while defining the step.

The following should work. Hope this helps, thank you!

<Step>
<Name>VerifyAPIKey</Name>
<Condition>extractvar = 0</Condition>
</Step>

Hi Nisha,

Thanks for the answer. it really helped.

I couldn't find this in apigee documentation. Can you please the link where it is mentioned.

Thanks once again.

Thanks Nisha for the quick reply. May be I miss read the specifics....

@krushna.padhee.ap , Make sure you wrap the condition using round brackets. It might not work otherwise.

<Step>
	<Name>VerifyAPIKey</Name>
	<Condition>(extractvar = 0)</Condition>
</Step>

@Anil Sagar

It works fine if there is one condition (cross-verified), brackets are required when there are more than one condition.

Yes I also agreed to that Nisha.