Not able to save + sign in APIGEE X KVM

I wanted to save user credentials in KVM, and in the password I have a special character (+) plus. When I save password the KVM remove plus sign with space. 

Can someone please help if they have encounter the same issue. how can I resolve this. KVM 

Solved Solved
1 2 172
1 ACCEPTED SOLUTION

When I save password the KVM remove plus sign with space.

How are you saving the password into the KVM? Are you using the UI, or the API? And this is Apigee X? (you tagged your question with aPigee X)

I just tried this

 

POST :apigee/v1/organizations/:org/environments/:env/keyvaluemaps/:kvm/entries
Authorization: Bearer :token
Content-Type: application/json

{"name":"entry-3", "value":"key+Value2"}

 

And then queried the entries

 

GET :apigee/v1/organizations/:org/environments/:env/keyvaluemaps/:kvm/entries
Authorization: Bearer :token

 

and saw this:

 

{
  "keyValueEntries": [
    {
      "name": "entry-3",
      "value": "key+Value2"
    }
  ],
  "nextPageToken": ""
}

 

So it works for me. What are you doing differently?

When you say "remove plus sign with space", maybe you mean "REPLACE plus sign with space" ? That can happen if you run your content through a URL-decoder. The + is a shorthand for a space (0x0020) character in URL Encoding (cite). Are you passing the value in a URL somehow? If you are using the documented REST API for Apigee KeyValueMaps, then I think you should not be passing the value of the KVM in a URL.

Maybe you have an API Proxy that is set up to accept input via URL query params? And then within the API proxy you have a KeyValueMapOperations policy to PUT the value into the KVM? That would cause the + to magically transform into a space. The solution to that is to URI-encode the + on the client (caller) side (via somethiing like JavaScript's encodeURIComponent()) . So if your password was something+else , and you are passing that in a query param, you would need to encode that to something%2Belse before invoking the request.

View solution in original post

2 REPLIES 2

When I save password the KVM remove plus sign with space.

How are you saving the password into the KVM? Are you using the UI, or the API? And this is Apigee X? (you tagged your question with aPigee X)

I just tried this

 

POST :apigee/v1/organizations/:org/environments/:env/keyvaluemaps/:kvm/entries
Authorization: Bearer :token
Content-Type: application/json

{"name":"entry-3", "value":"key+Value2"}

 

And then queried the entries

 

GET :apigee/v1/organizations/:org/environments/:env/keyvaluemaps/:kvm/entries
Authorization: Bearer :token

 

and saw this:

 

{
  "keyValueEntries": [
    {
      "name": "entry-3",
      "value": "key+Value2"
    }
  ],
  "nextPageToken": ""
}

 

So it works for me. What are you doing differently?

When you say "remove plus sign with space", maybe you mean "REPLACE plus sign with space" ? That can happen if you run your content through a URL-decoder. The + is a shorthand for a space (0x0020) character in URL Encoding (cite). Are you passing the value in a URL somehow? If you are using the documented REST API for Apigee KeyValueMaps, then I think you should not be passing the value of the KVM in a URL.

Maybe you have an API Proxy that is set up to accept input via URL query params? And then within the API proxy you have a KeyValueMapOperations policy to PUT the value into the KVM? That would cause the + to magically transform into a space. The solution to that is to URI-encode the + on the client (caller) side (via somethiing like JavaScript's encodeURIComponent()) . So if your password was something+else , and you are passing that in a query param, you would need to encode that to something%2Belse before invoking the request.

Hi ,

Yes its Apigee X. I am using KeyValueMap Policy for set and getting values from KVM. I figure out that in my case for my password which contain + sign, I should pass '%2B' in place of + sign.