Reputation: 2517
Setting Content-Type for GET method is not getting populated using Apache Camel-Http component.
exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/json");
Whereas the same is working when using POST method.
Understood that there is no body for method GET. A strange thing is, if body is set to empty string("") Content-Type is being passed but the method type also changes to POST.
exchange.getIn().setBody("");
2.13.1 is the Camel version that i am currently using. Tried with the latest versions too, still the same. Is there something that i am missing.
Service mandates to pass Content-Type.
Upvotes: 1
Views: 1211
Reputation: 1666
In the Camel source there is a test for this kind of scenario: https://github.com/apache/camel/blob/master/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProducerContentTypeTest.java
In both the test cases the body need to be set. You should see this in camel-http4:
and camel-http too:
If you decide to use Http4/http component then you'll need to set a body.
There is also this very old discussion on nabble: http://camel.465427.n5.nabble.com/Http4-Set-Header-Content-Type-not-passing-through-to-the-HTTP-Request-td5746414.html
Upvotes: 0