context.getVariable("app.MyVar") works in one revision and not in another?

I have this line in some javascript validation code on multiple API proxies:

var appMyVar = context.getVariable('app.MyVar');

In earlier revisions, this value accurately retrieves the value configured on the App associated with the Oauth credentials for the current token. However, on later revisions, this line of code sets appMyVar to null. I can switch from revision 3 where I know it works to revision 8 where it does not and back to revision 3 and it works again.

Has this been deprecated? Is there a better way to retrieve this value from the App configuration? 

Solved Solved
0 3 99
1 ACCEPTED SOLUTION

OK, that sounds frustrating.

With words like "earlier revisions" and "later revisions", you're talking about revisions of the API proxy? I'll assume so.

Has this been deprecated? Is there a better way to retrieve this value from the App configuration?

No, and no.

I suspect something has changed between your revision 3 and your revision 8, which results in the context variable app.MyVar to be empty.

  • EITHER it was never set (because maybe the VerifyAccessToken has not been called)
  • OR it was over-written or removed

If I were diagnosing this I would include a policy like this, attached at multiple points within the proxy flow. Then use a trace session to see if and when that variable gets set and unset.

 

<AssignMessage name='AM-Diagnostics'>
  <AssignVariable> 
    <Name>diags</Name> 
    <Ref>app.MyVar</Ref>
    <Value>-empty-</Value> <!-- this gets used if the named variable is empty -->
  </AssignVariable>
</AssignMessage>

 

That should give you better visibility into what is happening.

Good luck!

View solution in original post

3 REPLIES 3

OK, that sounds frustrating.

With words like "earlier revisions" and "later revisions", you're talking about revisions of the API proxy? I'll assume so.

Has this been deprecated? Is there a better way to retrieve this value from the App configuration?

No, and no.

I suspect something has changed between your revision 3 and your revision 8, which results in the context variable app.MyVar to be empty.

  • EITHER it was never set (because maybe the VerifyAccessToken has not been called)
  • OR it was over-written or removed

If I were diagnosing this I would include a policy like this, attached at multiple points within the proxy flow. Then use a trace session to see if and when that variable gets set and unset.

 

<AssignMessage name='AM-Diagnostics'>
  <AssignVariable> 
    <Name>diags</Name> 
    <Ref>app.MyVar</Ref>
    <Value>-empty-</Value> <!-- this gets used if the named variable is empty -->
  </AssignVariable>
</AssignMessage>

 

That should give you better visibility into what is happening.

Good luck!

Your solution helped me realize I failed to re-enable "verify oauth token" policy after debugging. 🙄

¡headslap! 

I'm glad you got it sorted out.