在mule 4 http连接器中发送json对象作为标头时出现错误



我的Https头在Mule http请求者中是这种格式

%dw 2.0 
output application/java
{    "Content-Transfer-Encoding" :"base64",
"X-do-Authentication" : {"Username": "xxx@yyy.org","Password": "xxxyyy","IntegratorKey": "4xzzzz"}
}

当尝试以这种格式发送报头时,我得到这个错误

Message               : "java.lang.IllegalStateException - No read or write handler for Username
java.lang.IllegalStateException: No read or write handler for Username
at org.mule.weave.v2.module.pojo.reader.PropertyDefinition._type$lzycompute(PropertyDefinition.scala:44)
at org.mule.weave.v2.module.pojo.reader.PropertyDefinition._type(PropertyDefinition.scala:35)
at org.mule.weave.v2.module.pojo.reader.PropertyDefinition.classType(PropertyDefinition.scala:70)

我尝试将输出设置为文本/普通,但这仍然不工作,我怎么能继续这个。我正在使用Mule 4

HTTP Headers不支持JSON Object作为值。我认为你需要在header中传递JSON字符串。换句话说,您只需要将JSON转换为String。您可以使用write函数来执行

%dw 2.0 
output application/java
---
{    "Content-Transfer-Encoding" :"base64",
"X-do-Authentication" : write({"Username": "xxx@yyy.org","Password": "xxxyyy","IntegratorKey": "4xzzzz"}, "application/json", {indent: false})
}

你必须重写对象:{"Username": "xxx@yyy.org","Password": "xxxyyy","IntegratorKey": "4xzzzz"}通过使用:write({"Username": "xxx@yyy.org","Password": "xxxyyy","IntegratorKey": "4xzzzz"}, "application/json")

相关内容

最新更新