在我的 quarkus 代码中有以下Apache Camel 路线:
rest("/")
.get("/v*").to(MY_SERVICE)
.post("/v*").to(MY_SERVICE)
.put("/v*").to(MY_SERVICE)
.delete("/v*").to(MY_SERVICE)
当我使用以下代码发送包含表单数据的POST请求时:
given().urlEncodingEnabled(true)
.param("email_address", "user@example.com")
.post("/v3/test");
出现以下错误:
ERROR [org.apa.cam.pro.err.DefaultErrorHandler] (vert.x-worker-thread-1) Failed delivery for (MessageId: 2B577A1B8400C13-0000000000000001 on ExchangeId: 2B577A1B8400C13-0000000000000001). Exhausted after delivery attempt: 1 caught: org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: {email_address=user@example.com} of type: java.util.HashMap on: Message[2B577A1B8400C13-0000000000000001]. Caused by: No type converter available to convert from type: java.util.HashMap to the required type: java.io.InputStream with value {email_address=user@example.com}. Exchange[2B577A1B8400C13-0000000000000001]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: java.util.HashMap to the required type: java.io.InputStream with value {email_address=user@example.com}]
Message History (complete message history is disabled)
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[route10 ] [route10 ] [from[platform-http:///v*?httpMethodRestrict=POST] ] [ 12]
...
[route6 ] [toD3 ] [{{mailgun.url}}${headers.CamelHttpUri}?bridgeEndpoint=true&throwExceptionOnFai] [ 0]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
: org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: {email_address=user@example.com} of type: java.util.HashMap on: Message[2B577A1B8400C13-0000000000000001]. Caused by: No type converter available to convert from type: java.util.HashMap to the required type: java.io.InputStream with value {email_address=user@example.com}. Exchange[2B577A1B8400C13-0000000000000001]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: java.util.HashMap to the required type: java.io.InputStream with value {email_address=user@example.com}]
at org.apache.camel.support.MessageSupport.getMandatoryBody(MessageSupport.java:117)
at org.apache.camel.component.http.HttpProducer.createRequestEntity(HttpProducer.java:576)
at org.apache.camel.component.http.HttpProducer.createMethod(HttpProducer.java:477)
at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:118)
at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:66)
at org.apache.camel.processor.SendDynamicProcessor.lambda$process$0(SendDynamicProcessor.java:195)
at org.apache.camel.support.cache.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:317)
at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:180)
at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:395)
at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:60)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:147)
at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:312)
at org.apache.camel.component.platform.http.vertx.VertxPlatformHttpConsumer.lambda$handleRequest$2(VertxPlatformHttpConsumer.java:184)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.util.HashMap to the required type: java.io.InputStream with value {email_address=user@example.com}
at org.apache.camel.impl.converter.CoreTypeConverterRegistry.mandatoryConvertTo(CoreTypeConverterRegistry.java:275)
at org.apache.camel.support.MessageSupport.getMandatoryBody(MessageSupport.java:115)
... 18 more
出了什么问题?怎么解决?
1条答案
按热度按时间mgdq6dx11#
尝试使用
formParams
方法发送表单数据: