Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

KVM is not updating the values

Not applicable
Hi, I have created one sample KVM to set the incremented values but it looks like it is always taking the initial values even through I'm using override="true" in KVM put. Expected functionality is, KVM will have the updated/incremented value from Java script after setting it into context. Not sure where I'm doing wrong. Please find the attached sample for the reference and help me out fixing this. Thanks!
Solved Solved
2 3 702
1 ACCEPTED SOLUTION

Thank for the question, and the code. I see you've got a couple problems in that API Proxy. For one thing, the order of policies you ran was:

JavaScript-1 putUrl getUrl

The Javascript was the thing that incremented the value. But it was starting from zero always, so it always incremented 0, resulting in a 1. The KVM PUT then stored the value 1, and the KVM Get then retrieved the value of 1.

Running it again, the same thing happened. Always 1.

There were some other problems too. For example with the KVM operations - you were referring to a variable in the key parameter of urlencoding.requesturl.hashed. Like this:

<Parameter ref="urlencoding.requesturl.hashed"/> 

the ref="..." indicates that the parameter is a variable. But no such variable exists in the context.

Anyway, I've fixed up an API proxy that demonstrates the use of the KVM to store an incremented value for each additional request. Find it attached. To use it, deploy it to any Edge org + env. The invoke it like this:

curl -i http://ORG-ENV.apigee.net/1080-kvm/t1
you should see something like
{
  "status" : true,
  "numalerts" : "4"
}

...after the 4th invocation.

View solution in original post

3 REPLIES 3