I have key value map under environment, say with mapIdentifier "routing".
I have apiproxy which accepts post method with json payload of key value pair.
First, I am extracting the payload, then parsing them using javascript as below:
if(context.flow=="PROXY_REQ_FLOW"){ var payload = context.getVariable("envInfo"); var jsonObject = JSON.parse(payload); var jsonObj = jsonObject[0]; // to get rid of extra list wrapper for (var i = 0; i < jsonObj.length; i++){ var obj = jsonObj[i]; print("key:" + obj.key); print("value:" + obj.value); } }
I have keyvaluemapoperation policy which just update only one key-value pair.
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Set-Up-Key-Value-Map-Routing" mapIdentifier="routing"> <DisplayName>Set Up Key Value Map Routing</DisplayName> <Properties/> <ExclusiveCache>false</ExclusiveCache> <ExpiryTimeInSecs>-1</ExpiryTimeInSecs> <Put override="true"> <Key> <Parameter ref="key"/> </Key> <Value ref="value"/> </Put> <Scope>environment</Scope> </KeyValueMapOperations>
What is the best way to update/insert all key value pairs ? Is there any way to put this KeyValueMapOperations policy in loop of javascript?
There are probably other ways to do it. One way I can think of is:
1: Create a proxy with just the KeyValue Map Policy
2: Use JavaScript to call that endpoint async (http://docs.apigee.com/api-services/reference/javascript-object-model) - look under "Making JavaScript callouts with httpClient".
Thanks @Srinandan Sridhar. That works, but it seems making lots of call.
Something like below is good:
but that works only to create, while for update operation, it says deprecated.
So, do we have some alternative for this deprecated service?
Please check if your org is CPS enabled - You can check by following the steps mentioned here
If it is, then the API used to create KVM is here and to update, you can look here.
NOTE: You can create KVM at different levels, please look at the documentation and use the appropriate Update/Create Mgmt APIs for your use case.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |