Search code examples
dataweavemulesoftmule4

Getting Error while sending json objects as headers in mule 4 http connector


my Https header is in this format in Mule http requester

%dw 2.0 
output application/java
{    "Content-Transfer-Encoding" :"base64",
    "X-do-Authentication" : {"Username": "[email protected]","Password": "xxxyyy","IntegratorKey": "4xzzzz"}
}

whem trying to send header in this format I am getting this error

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)

I tried setting output to text/plain but this is still not working how can I proceed on this. I am using Mule 4


Solution

  • You have to rewrite the object: {"Username": "[email protected]","Password": "xxxyyy","IntegratorKey": "4xzzzz"} to JSON by using: write({"Username": "[email protected]","Password": "xxxyyy","IntegratorKey": "4xzzzz"}, "application/json")