Is it possible to write to the KVM from within a javascript Policy?

Not applicable

Is there any way to store js variable into key value pair in javascript policy?

0 3 927
3 REPLIES 3

Alternatively you can create key-value in the form of json -

        var mapVariable = {};
        mapVariable.key1= "value1";
        mapVariable.key2 = "value2"
        
        request.setVariable("myMap", mapVariable) 





I think the question is about the Apigee Edge KVM.

No.

The Apigee Edge KVM is accessible via the KeyValueMapOperations policy.

You can dynamically generate a value in JS, and then use that value in the KVM-Put.

<KeyValueMapOperations name='KVM-Put-1' mapIdentifier='nameOfMap'>
  <Scope>environment</Scope>
  <Put override='true'>
    <Key>
      <Parameter ref='variable.containing.key'/>
    </Key>
    <Value ref='variable.containing.value.to.store'/>
  </Put>
  <ExpiryTimeInSecs>60</ExpiryTimeInSecs>
</KeyValueMapOperations>
<br>