Claus Ibsen created CAMEL-25309:
-----------------------------------
Summary: camel-http - a Map or List body says to marshal it to
JSON first
Key: CAMEL-25309
URL: https://issues.apache.org/jira/browse/CAMEL-25309
Project: Camel
Issue Type: Improvement
Components: camel-http
Reporter: Claus Ibsen
When the message body is a {{Map}} or a {{List}} (typically after {{unmarshal:
json}}, or a body built as a map), the HTTP producer fails with
{noformat}InvalidPayloadException: No body available of type:
java.io.InputStream but has type: java.util.LinkedHashMap on: order-1001.json.
Caused by: No type converter available to convert from type:
java.util.LinkedHashMap to the required type: java.io.InputStream{noformat}
That names the conversion, not what to do. Found in the local-model benchmark
(contracts/openapi-client, a rest-openapi call to a JSON operation through
camel-http): 3 of 5 runs failed on it, the model not seeing that the body must
be JSON text.
*Proposal:* in {{HttpProducer.createRequestEntity}}, when the body is a Map or
a Collection and cannot become a stream, keep the exception type and add a
hint: a Map or List is not an HTTP request body; marshal it to JSON first
({{marshal: json}}) or set the body to the JSON text.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)