GetKeys KVM method is returning an exception.

Not applicable

So we're trying to create a Service Locator API and we want to store a list of our API's in our environment configuration.


Unfortunately, when we try to use the method as it is defined in the documentation in our node.js file, we get errors. Here is the line in question that is throwing and error:

var kvm = apigee.getKeyValueMap('taco', 'environment');

kvm.getKeys(function(err, keys_array)

{ res.send(err); }

);


Here we are sending the error, because sending keys_array returns null. The error is this message:


{ "message": "com.apigee.kernel.exceptions.spi.UncheckedException{ code = keyvaluemap.service.KeyValueMapOperationNotSupported, message = KeyValueMap Operation createKeyValueMapEntry is not supported for the organization ThisIsOurOrgName, associated contexts = []}" }

Are we using a version of Apigee that doesn't support this operation? Why is that? How do we get access to this method?

Any assistance would be greatly appreciated.

0 8 873
8 REPLIES 8

Hi @Samuel Sayler,

can you please paste full code written in node.js.

Thanks,

Santosh

Sure, here you go:

var express = require('express')

var apigee = require('apigee-access')

var app = express()

app.get('/', function (req, res)

{

var kvm = apigee.getKeyValueMap('taco', 'environment');

kvm.getKeys(function(err, keys_array)

{

res.send(err);

} );

})

app.listen(3000, function () { console.log('started up.') })

I mentioned it in the above statement, but I know the code I posted is sending the error message, but the keys_array value is simply undefined

@Samuel Sayler : I can see the code snippet works fine. ie., i retrieved the KeyValueMap (named as TestKVM) from my environment(test). Please ensure the KVM Identifier created in correct environment(test / prod/ or customised one).

var express = require('express') 

var apigee = require('apigee-access') 
var app = express() 

app.get('/', function (req, res){ 

var kvm = apigee.getKeyValueMap('testKVM', 'environment');

kvm.getKeys(function(err, keys_array) {
     console.log("All KVM => " , keys_array);
     res.send (keys_array);
//res.send(err);
} );

}) app.listen(3000, function () { console.log('started up.') })

4753-nodejslogs.jpg

4754-nodejs-kvm.jpg

If this issue different then please provide bit more details. Hope it helps.

Is it possible I'm on an incorrect version that does not support the stated method?

Yes, it is possible. But first, check that the KVM exists, please? Sabthar asked you to verify that, but I didn't see you confirm that you have checked. The error message you are getting is:

createKeyValueMapEntry is not supported for the organization 

.... which is a little but odd, because it suggests that your call to "getKeys()" is resulting in a call to createKeyValueMapEntry(). It could be a broken error message though. Anyway to check that the KVM exists, please do this:

curl -i -u $USERNAME https://api.enterprise.apigee.com/v1/o/ThisIsOurOrgName/e/$YOURENVIRONMENT/keyvaluemaps/taco 

You must replace USERNAME and YOURENVIRONMENT with the appropriate values.

You should see a 200 OK, and some information about the KVM.

If that checks out, then can you please run this:

curl -i -u $USERNAME https://api.enterprise.apigee.com/v1/o/ThisIsOurOrgName

...and show us the results?

It is possible that your org is not "CPS Enabled". CPS is an internal name for a data storage subsystem we use in the Edge cloud. It's an internal name but you may see it mentioned in some of the Edge documentation. There are some organizations that don't use CPS and for those I *think* the getKeys() call will not succeed.

Anyway do the checks and let us know.

I'm getting a (60) SSL certificate problem: unable to get local issuer certificate.

The last thing you mentioned sounds like it may be the issue.

The last useful piece of information I may be able to offer is that I'm pretty sure the KVM is working, since the singular getKey method works and returns the proper value, it's only when I'm trying to get all of them as an array that it doesn't work.

Not sure if this question was resolved later on. I landed here today because I was facing the same issue while making an "Update KVM entry" operation.

{
    "code": "keyvaluemap.service.KeyValueMapOperationNotSupported",
    "message": "KeyValueMap Operation CreateKeyValueMapEntry is not supported for the organization MyOrg",
    "contexts": []
}

It turns out this operation is only supported on Public cloud and I was trying it on a Private cloud/On-Prem installation. Ref: this. So ended up updating the entire KVM instead which is supported only on Private Cloud and not on Public Cloud. Ref: this. Strange!