Why values from KeyValueMapOperations are empty?

Not applicable

Hi everybody.

I have the following problem with apigee

I made

2434-1.jpg

2435-2.jpg

And describe it in flow

2433-4.jpg

But when I try to get access to my backend api, I get the following problem

2436-4.jpg

Why this variable is empty?? Password issue is the same.

P.S. I try to map credentials on my Environment variables

2437-5.jpg

so what am I doing wrong?

Solved Solved
0 8 499
1 ACCEPTED SOLUTION

HI @Oleksandr Skoryi

What is the value you are expecting for those variables that are used as ref within the policy? From your screenshot, I see the variables are not being set. You might want to use the KVM key directly as parameter. See below

In your getUsername policy - change the config to

<Get assignTo="credentials.username" index="1">
        <Key>
            <Parameter>username</Parameter>
        </Key>
    </Get>

View solution in original post

8 REPLIES 8

Hi Oleksandr Skoryi,

You can find discussion on similar issue here.

HI @Oleksandr Skoryi

What is the value you are expecting for those variables that are used as ref within the policy? From your screenshot, I see the variables are not being set. You might want to use the KVM key directly as parameter. See below

In your getUsername policy - change the config to

<Get assignTo="credentials.username" index="1">
        <Key>
            <Parameter>username</Parameter>
        </Key>
    </Get>

Adding on - instead of 2 KVM get policies, you can have one policy called "getUserCredentials" with two Get operations

<Get assignTo="credentials.username" index="1">
        <Key>
            <Parameter>username</Parameter>
        </Key>
    </Get>

<Get assignTo="credentials.password" index="1">
        <Key>
            <Parameter>password</Parameter>
        </Key>
    </Get>

I want to get values from key-value pair from environment configuration variables

2438-6.jpg

I did like you said. But as for as you can see i get 500. And values credentials.password and credentials username are empty.

Here is my KeyValue file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="GetCredentials" mapIdentifier="Credentials" continueOnError="false">
    <Get assignTo="credentials.username" index="1">
        <Key>
            <Parameter>user</Parameter>
        </Key>
    </Get>
    <Get assignTo="credentials.password" index="1">
        <Key>
            <Parameter>1234</Parameter>
        </Key>
    </Get>
</KeyValueMapOperations>

Hi

Looks like you are passing the actual value in your policy. You should be using the key - in your case "username" and "password"

Just replace your policy with the one below and let me know if it works:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations name="GetCredentials" mapIdentifier="Credentials" continueOnError="false">
    <Get assignTo="credentials.username" index="1">
        <Key>
            <Parameter>username</Parameter>
        </Key>
    </Get>
    <Get assignTo="credentials.password" index="1">
        <Key>
            <Parameter>password</Parameter>
        </Key>
    </Get>
</KeyValueMapOperations>

The values are fetched from KVM and stored in the variables you created - in this case they are "credentials.username" and "credentials.password"

At last, everything works. Thanks a lot!

Glad it worked !! Please continue posting questions, ideas, etc on community..