You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Shabin5785 <sh...@outlook.com> on 2016/09/27 10:13:34 UTC

Http post Request returns 400 error

I have a camel route configured for reading from a JMS queue and POST it to a
service. My route is :

from("jms:queue")
.marshal()
.json(JsonLibrary.GSON)
.setHeader(Exchange.CONTENT_TYPE,constant("application/json"))
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.process(new Processor1())
.to("https4:xxxxxx?throwExceptionOnFailure=false")
.process(new MyProcessor());

My Configuration for setting my auth details.

HttpComponent httpc =
getContext().getComponent("http4",HttpComponent.class);
httpc.setHttpConfiguaration(customHttpConfig())

*I am getting a 400 error from the server. But i am able to hit the server
from Postman api and get successful response.*

In my Processor1 class ( before making the request), i am able to print the
body of the message, which contains a json representation of my object.

But in the processor after the POST request, i am doing this and getting
below responses:

Message in = exchange.getIn();
in.getBody(String.class); // print the error code 400
HttpServletRequest request = in.getBody(HttpServletRequest.class)// This is
null.

Anything i am doing wrong? Do i need to set the message Content to the body
of my Post Request?




--
View this message in context: http://camel.465427.n5.nabble.com/Http-post-Request-returns-400-error-tp5788101.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Http post Request returns 400 error

Posted by Shabin5785 <sh...@outlook.com>.
Great .That worked :)

Are the  headers from the JMS message that i am receiving being passed on to
the POST call as well? I thought only the relevant headers for http call 
will be passed on.



--
View this message in context: http://camel.465427.n5.nabble.com/Http-post-Request-returns-400-error-tp5788101p5788116.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Http post Request returns 400 error

Posted by mihaivoicu7 <vo...@gmail.com>.
Hello,

Try to remove all readers and add just the content-type and method
.removeHeaders("*")
.setHeader(Exchange.CONTENT_TYPE,constant("application/json")) 
.setHeader(Exchange.HTTP_METHOD, constant("POST")) 

After that just see what header caused the problem and handle it somehow.



--
View this message in context: http://camel.465427.n5.nabble.com/Http-post-Request-returns-400-error-tp5788101p5788107.html
Sent from the Camel - Users mailing list archive at Nabble.com.