Hi Ah yeah the put in the rest url should take precedence. Can you log a JIRA ticket.
On Wed, May 17, 2017 at 2:07 PM, owain <owain@integration.technology> wrote: > I have swapped out a route previously using http4 directly for the more > succinct newly released producer DSL. > > What was working as: > > from("direct:getCounter") > .routeId("i4ip-Get-Counter") > .setHeader("CamelHttpMethod", constant("PUT")) > > .to("http4://{{counter.service.host}}:{{counter.service.port}}/api/counter/{{counter.name}}") > .unmarshal().json(JsonLibrary.Jackson,CounterPojo.class) > .setBody().simple("${body.getCounter()}") > .convertBodyTo(Integer.class) > .log(LoggingLevel.INFO, "returned ${body} for counter: > {{counter.name}}") > ; > > I changed to: > > > restConfiguration().host("{{counter.service.host}}").port("{{counter.service.port}}"); > > from("direct:getCounter") > .routeId("i4ip-Get-Counter") > *.setHeader("CamelHttpMethod", constant(HttpMethods.PUT))* > .to("rest:*put*:api/counter/{{counter.name}}") > .unmarshal().json(JsonLibrary.Jackson,CounterPojo.class) > .setBody().simple("${body.getCounter()}") > .convertBodyTo(Integer.class) > .log(LoggingLevel.INFO, "returned ${body} for counter: > {{counter.name}}") > ; > } > > I was getting a 404 because the PUT request was being transformed to a POST > since http4/HttpMethodHelper > <https://github.com/apache/camel/blob/master/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpMethodHelper.java> > turns a request to POST if there is a payload. My PUT has a payload but it > the method in the URI is ignored. However you can manually set the header > as above and it works fine. > > Not sure whether this is for non http4 libraries. The example in the camel > source code for the DSL producer is just a GET. > https://github.com/apache/camel/tree/master/examples/camel-example-rest-producer > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/2-19-0-Rest-Producer-DSL-http4-support-for-PUT-workaround-tp5799706.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2