This is the code generated in Integration Studio. I'm hitting an API through my production endpoint. I'm converting the payload from XML to JSON, and I can see the payload successfully converted in the logs. However, whenever it reaches the backend, it becomes null.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/props" name="props_api" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<payloadFactory media-type="json" template-type="freemarker">
<format>{
"name": "${payload.root.user.name}",
"description": "${payload.root.user.description}"
}</format>
<args>
<arg evaluator="xml" expression="//root/user/name"/>
<arg evaluator="xml" expression="//root/user/description"/>
</args>
</payloadFactory>
<header name="Content-Type" scope="transport" value="application/json"/>
<log level="full"/>
<send>
<endpoint>
<address uri="http://127.0.0.1:8000/drinks/">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</address>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
Here's the payload:
<root>
<user>
<name>s</name>
<description>dd</description>
</user>
</root>
The payload is successfully converted from XML to JSON, as seen in the logs:
{
"name": "s",
"description": "dd"
}
However, whenever it reaches the backend, it becomes null. Here's the error log:
[2023-02-26 18:13:21,282] INFO {LogMediator} - {api:props_api} To: /props, MessageID: urn:uuid:e5b8eb0f-85d0-4150-a284-1292b6c902be, correlation_id: e5b8eb0f-85d0-4150-a284-1292b6c902be, Direction: request, Payload: {
"name": "s",
"description":"dd"
}
[2023-02-26 18:13:21,282] INFO {LogMediator} - {api:props_api} To: /props, MessageID: urn:uuid:e5b8eb0f-85d0-4150-a284-1292b6c902be, correlation_id: e5b8eb0f-85d0-4150-a284-1292b6c902be, Direction: request, Payload: {
"name": "s",
"description": "dd"
}
[2023-02-26 18:13:21,306] ERROR {TargetHandler} - HTTP protocol violation : Not a valid protocol version: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" For : 127.0.0.1:8000 org.apache.http.ProtocolException: Not
Try using an HTTP Endpoint rather than an address endpoint.
<endpoint>
<http method="post" uri-template="http://127.0.0.1:8000/drinks">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
If that doesn't work, enable the Wirelogs as Sanoj mentioned and share the logs.