title: Mule ESB - How to call a API via HTTP POST method (sending parameters along)
body: <p>Its me again.</p>
  
  <p>I am trying to create a flow that will post a a job opening to a job portal. They expose their API via a Post method. I am not sure how to pass the values to the HTTP end-point.
  This is just a testing sample with hard coded values in it. when it works will I have the flow pick-up the values from a database.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;mule xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
          xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
      http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd"&gt;
          &lt;http:connector name="HTTP_CONFIG" cookieSpec="netscape" validateConnections="false" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" clientSoTimeout="100000" serverSoTimeout="100000" socketSoLinger="0" proxyHostname="pta-proxy.work.co.za" proxyPort="3128" doc:name="HTTP\HTTPS" /&gt;
          &lt;flow name="career24Flow1" doc:name="career24Flow1"&gt;
              &lt;http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" doc:name="HTTP" contentType="text/plain"/&gt;       
              &lt;message-properties-transformer  doc:name="Set the  post Values" &gt;
                  &lt;add-message-property key="apikey" value="XXXX"/&gt;
                  &lt;add-message-property key="integrationkey" value="567"/&gt;
                  &lt;add-message-property key="consultantemail" value="integrations@work.com"/&gt;
                  &lt;add-message-property key="title" value="Testing Mule API"/&gt;
                  &lt;add-message-property key="reference" value="33175"/&gt;
                  &lt;add-message-property key="jobtypeid" value="1"/&gt;
                  &lt;add-message-property key="closingdate" value="01/06/2014"/&gt;
                  &lt;add-message-property key="location" value="66"/&gt;
                  &lt;add-message-property key="salaryfrom" value="10000.00"/&gt;
                  &lt;add-message-property key="salaryto" value="20000.00"/&gt;
                  &lt;add-message-property key="salaryunitid" value="4"/&gt;
                  &lt;add-message-property key="description" value="Testing the Mule ESB to post to the portal"/&gt;
                  &lt;add-message-property key="companyname" value="CSIR"/&gt;
                  &lt;add-message-property key="sectorids" value="17"/&gt;
                  &lt;add-message-property key="applicationmethodid" value="2"/&gt;
                  &lt;add-message-property key="applicationurl" value="http://www.testing.com"/&gt;
                  &lt;add-message-property key="package" value="2"/&gt;
              &lt;/message-properties-transformer&gt;
              &lt;http:outbound-endpoint exchange-pattern="request-response" host="api.work.com" port="80" method="POST" doc:name="Post on Career24"  path="_integrations/httppost/vacancy.ashx" connector-ref="HTTP_CONFIG" contentType="application/x-www-form-urlencoded"/&gt;
  
          &lt;/flow&gt;
      &lt;/mule&gt;
  </code></pre>
  
  <p>I get this back from the site so it seems the values are not being sent via the HTTP end-point.</p>
  
  <pre><code>ERROR:
  - Field &amp;#39;apikey&amp;#39;, is required.
  - Field &amp;#39;integrationkey&amp;#39;, is required.
  - Field &amp;#39;consultantemail&amp;#39;, is required.
  - Field &amp;#39;title&amp;#39;, is required.
  - Field &amp;#39;reference&amp;#39;, is required.
  - Field &amp;#39;jobtypeid&amp;#39;, is required.
  - Field &amp;#39;closingdate&amp;#39;, is a required field.
  - Field &amp;#39;sectorids&amp;#39;, is required.
  - Field &amp;#39;location&amp;#39;, is required.
  - Field &amp;#39;description&amp;#39;, is required.
  - Field &amp;#39;applicationmethodid&amp;#39;, is required.
  </code></pre>
  
  <p>I have tried a "Message to HTTP Response" transformer as well but still no luck. </p>
  
  <p>Thanks for the help.</p>
  
  <p>Regards.</p>
  
  <p>Jaco.</p>