​ Key Value Maps Scope

5 3 1,864

While playing with Key Value Maps, which lets you store values for a global usage within your proxies, I stumbled upon a slight issue.

Whilst the documentation states that the scope of an key value map entry can be „organization", „environment", „apiproxy" or „policy" (http://apigee.com/docs/api-services/reference/key-value-map-operations-policy#ScopeElement), it does not specify how/where to create that key value map.

I first created my key value map using Postman like follows:

POST: https://api.enterprise.apigee.com/v1/organizations/MYORG/apis/MYPROXY/keyvaluemaps
Payload: { "name" : "mymap", "entry" : [ { "name" : "myentry", "value" : "myvalue" } ] }

When trying to get the „myentry“ value using a „KeyValueMapOperations“ policy in my proxy, it failed (no value returned) with the scope set to „environment“ and „organization“. I eventually found out that it did work with the scope set to „apiproxy“.

When creating the key value map on the organization level (as opposed to API proxy level used before), using the scope set to „environment“ or „organization“ works fine:

POST: https://api.enterprise.apigee.com/v1/organizations/MYORG/keyvaluemaps
Payload: { "name" : "mymap", "entry" : [ { "name" : "myentry", "value" : "myvalue" } ] }

So the scope of a „KeyValueMapOperations“ matters, and should match the scope/type of the key value map created in first place (Proxy, Org or Environment).

Hereunder the links to the documentation for the Proxy, Org and Env KVMs:

http://apigee.com/docs/api-reference/content/api-proxy-keyvalue-maps

http://apigee.com/docs/api-services/content/environment-keyvalue-maps

http://apigee.com/docs/api/keyvalue-maps

Comments
straut
Staff

Thanks, Sven. The topic for the KeyValueMapOperations policy now includes a note in the <Scope> element section about needing to be specific and consistent with the element value.

http://apigee.com/docs/api-services/reference/key-value-map-operations-policy#ScopeElement

kristianjaeger
New Member

Hello, can KVMs be added with ApiProxy scope via the Apigee UI or only through the management API? Thanks.

dchiesa1
Staff

Only through the Management API.

Version history
Last update:
‎06-08-2015 10:30 AM
Updated by: