How to set the http method (GET/POST/PUT/DELETE/HEAD/OPTIONS/TRACE) to the HTTP producer - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

Note: The http PATCH method is supported starting with Camel 2.11.3 / 2.12.1.

The HTTP4 component provides a way to set the HTTP request method by setting the message header. Here is an example;

from("direct:start")
   .setHeader(Exchange.HTTP_METHOD, 
       constant(org.apache.camel.component.http4.HttpMethods.POST))
   .to("http4://www.google.com")
   .to("mock:results");

The method can be written a bit shorter using the string constants:

.setHeader("CamelHttpMethod", constant("POST"))

And the equivalent Spring sample:

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
   <route>
      <from uri="direct:start"/>
      <setHeader headerName="CamelHttpMethod">
         <constant>POST</constant>
      </setHeader>
      <to uri="http4://www.google.com"/>
      <to uri="mock:results"/>
   </route>
</camelContext>