Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Is it possible to store JSON objects in the KVM?

Not applicable

Hi,

I am attempting to store the following example in the KVM. As you can see, the value is a JSON object.

{
  "entry": [
    { 
        "name": "kid1", 
        "value": {
            "components": {
                "n": "test1",
                "e": "test2"            
            }
        }
    },
    { 
        "name": "kid2", 
        "value": {
            "components": {
                "n": "test3",
                "e": "test4"  
            }
        }
    }
  ],
  "name": "test_kvm"
}

However, when I try and POST this in Postman, I get the following error.

{
  "message": "Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@6d839557; line: 4, column: 23] (through reference chain: com.apigee.keyvaluemap.resource.KeyValueMap[\"entry\"]->com.apigee.keyvaluemap.resource.KeyValueMapEntry[\"value\"])",
  "contexts": []
}

Does anyone know whether what I am doing wrong? Or whether it's possible to store JSON objects in the KVM?

FYI, in regards to JSON settings, I have set the body to "raw" and type to JSON(application/json).

Thanks,

Marlene

Solved Solved
0 6 3,325
1 ACCEPTED SOLUTION

Hi @marlene.pecotich,

You have to escape your JSON like below:

{  
 "name" : "Map_name",
 "entry" : [ 
  {
   "name" : "Key1",
    "value" : "{ \"name\": \"John\", \"work\" : \"Engineering\"}"
  } 
 ]
}

Also if your org supports CPS then you can directly create KVM with JSON using CPS management APIS as they support XML payload where you can use JSON string directly.

Payload for CPS:

<Entry name="Env_Key1">{ "name" : "John", "work": "Engineering"}</Entry>

Details of CPS Management APIs can be found at CPS Create KVM in environment.

Hope this helps

View solution in original post

6 REPLIES 6