Hi,
I've an issue using encrypted KVM, the Proxy works fine if I'm trying to get values from Un-encrypted KVM but the issue begins if I use an encrypted KVM
I see the query param in outbound request when I use un-encrypted KVM and the request is successful.
<Get assignTo="request.queryparam.key"> <Key> <Parameter>required_key</Parameter> </Key> </Get>
But when I try to use encrypted KVM I dont see the query param in outbound request and the request is failed.
<Get assignTo="private.request.queryparam.key"> <Key> <Parameter>required_key</Parameter> </Key> </Get>
Is there anything that I'm missing. I don't see any errors from processing the step but the backend returns error due to missing key.
Well let's see.
As you may be aware, there's a restriction when performing a GET using an encrypted KVM: the assignTo variable must have the prefix "private." I forget what happens if you don't use the private. prefix, I think you get a validation error at the time you try to save the API proxy. Whether you get the error then, or later, in any case , it won't work.
Variables named with the "private." prefix are treated specially in the Apigee Edge runtime. The values assigned to such variables will not be shown in the Edge Trace (Debugsession). This preserves privacy of the data.
I see you have used a name that begins with "private." and then finishes with "request.queryparam.key". And from that name, and from your example using the un-encrypted KVM, I am inferring that you'd like to set a queryparam named "key" with the data you retrieve from the encrypted KVM.
Two things on that.
The first policy without encrypted value works, since Apigee sees the reference as request.queryparam.key, which is a defined flow variable. In the second policy with private.request.param.key, Apigee will create a variable with name "private.request.query.param.key", the "private" is like a variable prefix. Variables request.param.key and private.request.param.key are hence not treated as the same variable references. That's the reason its not passed to your backend. You can test it by writing a JS policy to print the values
print(context.getVariable("request.queryparam.key"));
print("key value with private prefix");
print(context.getVariable("private.request.queryparam.key"));
You will see that the output of the first print statement will be empty, while the third statement will give you the required value.
You will need to explicitly set the value in request.queryparam.key using Assign Message or JavaScript policy, after retrieving the value from the KVM. Here is an example
<Get assignTo="private.request.queryparam.key"> <Key><Parameter>required_key</Parameter></Key> </Get>
<AssignMessage name="AM-Set-Key"> <Set> <QueryParams> <QueryParam name="key">{private.request.queryparam.key}</QueryParam> </QueryParams> </Set> <AssignTo type="request" transport="http" createNew="false"/> </AssignMessage>
this works; it is basically what I described in #3 in my answer.
User | Count |
---|---|
5 | |
2 | |
2 | |
1 | |
1 |