title: pecl_http add post request body in hotelbeds apitude
body: <p>Recently I started working with <a href="https://developer.hotelbeds.com/docs/read/Home" rel="nofollow">hotelbeds apitude PHP API</a></p>
  
  <p>I am trying to add <code>xml</code> code to a <code>POST</code> request body using <code>pecl_http</code>. I tried with following code -</p>
  
  <pre><code>$xml_part = &lt;&lt;&lt; EOD
                  &lt;&lt;&lt;XML PART&gt;&gt;&gt; EOD;
  
  $request = new http\Client\Request("POST",
                      $endpoint,
                      ["Api-Key" =&gt; $hotel_beds_config['api_key'],
                          "X-Signature" =&gt; $signature,
                          "Content-Type" =&gt; "application/xml",
                          "Accept" =&gt; "application/xml"],
                      $xml_part
                  );
  </code></pre>
  
  <p>I got the following error</p>
  
  <blockquote>
    <p>Fatal error: Uncaught TypeError: Argument 4 passed to http\Client\Request::__construct() must be an instance of http\Message\Body, string 
    given</p>
  </blockquote>
  
  <p>Then I tried with following code -</p>
  
  <pre><code>$request = new http\Client\Request("POST",
                      $endpoint,
                      ["Api-Key" =&gt; $hotel_beds_config['api_key'],
                          "X-Signature" =&gt; $signature,
                          "Content-Type" =&gt; "application/xml",
                          "Accept" =&gt; "application/xml"],
                      new http\Message\Body($xml_part)
  </code></pre>
  
  <p>Now I get following error -</p>
  
  <blockquote>
    <p>Fatal error: Uncaught http\Exception\InvalidArgumentException: http\Message\Body::__construct() expects parameter 1 to be resource, string given</p>
  </blockquote>
  
  <p>I get the documentation to add body message here -</p>
  
  <p><a href="https://mdref.m6w6.name/http/Message/Body" rel="nofollow">pecl_http</a></p>
  
  <p>How can I add the xml code to the <code>POST</code> request?</p>