I have a payload with many fields but i would like to send only the fields that they are not empty to the Backend ,so i tried to use enrich mediator to remove those fields if they are empty but i got an error .
This is my payload factory :
<payloadFactory media-type="json">
<format>
{
"_putupdateuser": {
"BADLOGINS": $1,
"EMAIL": "$2",
"FRAMED_ROUTE": "$3"
}
}
</format>
<args>
<arg evaluator="xml" expression="get-property('BADLOGINS')"/>
<arg evaluator="xml" expression="get-property('EMAIL')"/>
<arg evaluator="xml" expression="get-property('FRAMED_ROUTE')"/>
</args>
</payloadFactory>
This is my implementation of enrich mediator :
<enrich>
<source clone="false" xpath="json-eval($._putupdateuser.FRAMED_ROUTE)"/>
<target action="remove" type="body"/>
</enrich>
This is the error i got :
Caused by: com.google.gson.stream.MalformedJsonException: Unexpected value at line 3 column 32 path $._putupdateuser.BADLOGINS
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1568)