繁体   English   中英

无法以API读取wso2 ESB中的JSON请求主体参数

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

我已经在WSO2 ESB(4.8.1)中创建了一个API,我想使用请求正文将PUT请求发送到该API。 我已经尝试过该示例,并且想以已定义API的顺序记录属性值。

这是我的请求正文:

请求正文(JSON)

这是我尝试记录位置名称的方式:

XML日志

但我收到这样的错误:

(错误-SynapseJsonPath #stringValueOf。评估JSON路径时出错。返回空结果。错误>>>无效路径)

错误截图

那么我该如何读取这些值?

为了满足您的要求,您应该使用以下请求发送“ Content-Type” HTTP标头,

    "Content-Type : application/json"

在此处输入图片说明

然后,您可以记录特定的JSON元素,如下所示。

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

然后您可以看到以下日志,

在此处输入图片说明

谢谢。

If you want to get single variable from user in json request you can use this code 


Use This json:
    {

    "namee":"UsmanYaqooooooooooob"
    }


Api Code: 
        <api xmlns="http://ws.apache.org/ns/synapse" name="Hello" context="/hello">
           <resource methods="POST" uri-template="/post">
              <inSequence>
                 <log level="custom">
                    <property name="===========inSequence" value="****"></property>
                    <property name="locationsssssssss" expression="json-eval(.namee)"></property>
                 </log>
                 <payloadFactory media-type="json">
                    <format>{"hello":"world"}</format>
                    <args></args>
                 </payloadFactory>
                 <property name="messageType" value="text/xml"></property>
                 <respond></respond>
              </inSequence>
           </resource>
        </api>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM