title: Unsupported media type for xml php curl request
body: <p>Here is my code I am using to connect to the Mind Body Online API.  If ANYONE at all has any experience with this please point me in the right direction!</p>
  
  <p>The error I am getting is :The server cannot service the request because the media type is unsupported.</p>
  
  <p>Code:</p>
  
  <pre><code>$soapUrl = "http://clients.mindbodyonline.com/api/0_5/ClassService.asmx?WSDL";
  // xml post structure
  
  $xml_post_string = '&lt;?xml version="1.0" encoding=\"utf-8\"?&gt;
  &lt;soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;soapenv:Header/&gt;
    &lt;soapenv:Body&gt;
       &lt;GetClasses xmlns="http://clients.mindbodyonline.com/api/0_5/GetClasses"&gt;
          &lt;Request&gt;
             &lt;SourceCredentials&gt;
                &lt;SourceName&gt;{user}&lt;/SourceName&gt;
                &lt;Password&gt;{pass}&lt;/Password&gt;
                &lt;SiteIDs&gt;
                   &lt;int&gt;{id}&lt;/int&gt;
                &lt;/SiteIDs&gt;
             &lt;/SourceCredentials&gt;
             &lt;XMLDetail&gt;Basic&lt;/XMLDetail&gt;
             &lt;PageSize&gt;10&lt;/PageSize&gt;
             &lt;CurrentPageIndex&gt;0&lt;/CurrentPageIndex&gt;
             &lt;SchedulingWindow&gt;true&lt;/SchedulingWindow&gt;
          &lt;/Request&gt;
       &lt;/GetClasses&gt;
    &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  ';
  
  $headers = array(
      "Content-type: application/xml;charset=utf-8",
      "Accept: application/xml",
      "Cache-Control: no-cache",
      "Pragma: no-cache",
      "SOAPAction: http://clients.mindbodyonline.com/api/0_5/GetClasses",
      "Content-length: ".strlen($xml_post_string),
      );
  
  $url = $soapUrl;
  $cookiePath = tempnam('/tmp', 'cookie');
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
  // converting
  $response = curl_exec($ch);
  curl_close($ch);
  
  echo $response;
  </code></pre>