camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngthphat <>
Subject camel-Netty4 Consume multipart/form-data, curl doesn't work, works with postman
Date Mon, 14 Nov 2016 16:22:52 GMT
Hi all,I'm implementing a rest endpoint receive a multipart form data (upload
file). I did test my implementation with postman (chrome extension) and with
httpclient, both of them work well, except curl.*My
.description("Upload bank report")               
.post(CommonConstants.REPORT_UPLOAD_CONTEXT_PATH + "/{countryCode}")               
.process(processor);*My Processor:*HttpRequest request =
postRequestDecoder = new HttpPostRequestDecoder(request);with
HttpPostRequestDecoder, I can get MixedAttributes and MixedFileUpload as
expectation.*Test client side with httpclient:*        CloseableHttpClient
client = HttpClientBuilder.create().build();        File file = new
File("path_to_file");        String url = "url_to_rest_api";        HttpPost
post = new HttpPost(url);        FileBody fileBody = new FileBody(file,
ContentType.DEFAULT_BINARY);        StringBody stringBody1 = new
StringBody("value", ContentType.MULTIPART_FORM_DATA);       
MultipartEntityBuilder builder = MultipartEntityBuilder.create();       
builder.addPart("file", fileBody);        builder.addPart("key",
stringBody1);        HttpEntity entity =;       
post.setEntity(entity);        CloseableHttpResponse response =
client.execute(post);*However, when test with curl:*curl -s -i -X POST -H
"Content-Type: multipart/form-data" -F "data=@/path_to_file.xlsx" -F
"key=value" http://localhost:8595/url...curl return:HTTP/1.1 404 Not
FoundContent-Type: text/plainContent-Length: 0and log4j return:2016-11-14
22:34:47 WARN  NettyHttpConsumer:137 - HttpServerChannelHandler is not found
as attachment to handle exception, send 404 back to the unsupported message type:
DefaultFullHttpResponse (expected: ByteBuf, FileRegion)I'm using:camel
v2.17.3camel-netty4-http v2.17.3 java version "1.8.0_101MacOSQuestion1: Does
my approach to consuming multipart/form-data with HttpPostRequestDecoder is
correct?Question2: Does the root cause relate to curl or is there missing 
some configuration on my app?

View this message in context:
Sent from the Camel - Users mailing list archive at
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message