Search code examples
jsonwso2jsonpathwso2-esb

Cannot Read JSON request body parameters in wso2 ESB as an api


I have created an API in the WSO2 ESB (4.8.1) and I wanted to send a PUT request to that API with a request body. I have tried with the sample and I wanted to log a property values in the insequence of the defined API.

This is my request body:

request body (JSON)

This is the way how I tried to log the location name:

XML log

But I’m getting an error like this:

(ERROR - SynapseJsonPath #stringValueOf. Error evaluating JSON Path . Returning empty result. Error>>> invalid path)

error screenshot

So how can I read these values?


Solution

  • To achieve your requirement, you should send the "Content-Type" HTTP header with the request like below,

        "Content-Type : application/json"
    

    enter image description here

    Then you can log the specific JSON element like below.

     <log>
        <property name="location" expression="json-eval($.coordinates.location[0].name)"></property>
     </log>
    

    Then you can see following log,

    enter image description here

    Thanks.