title: Bad Request: XML cannot be parsed 400 error Curl PHP
body: <p>I am using PHP POST Curl request to pass XLM data but I am getting an error in response:</p>
  <blockquote>
  <p>Bad Request: XML cannot be parsed. Check the XML you are sending to
  make sure it can be parsed.</p>
  </blockquote>
  <pre><code>$url = 'https://provapi.advancedmd.com/processrequest/API-100/DOKTORCONNECT/xmlrpc/processrequest.aspx';
  
  $xmldata = '&lt;ppmdmsg action=&quot;addpatient&quot; class=&quot;demographics&quot; msgtime=&quot;3/20/2018 2:52:07 PM&quot;&gt;&lt;patientlist&gt;&lt;patient respparty=&quot;SELF&quot; name=&quot;smith,BOB&quot; sex=&quot;M&quot; genderidentity=&quot;&quot; genderidentityother=&quot;&quot; orientation=&quot;&quot; orientationother=&quot;&quot; hipaarelationship=&quot;18&quot; relationship=&quot;1&quot; dob=&quot;03/11/1952&quot;ssn=&quot;444-44-4444&quot; additionalmrn=&quot;&quot; chart=&quot;AUTO&quot; profile=&quot;prof18&quot; finclass=&quot;fclass16&quot; language=&quot;44&quot; inactivestatus=&quot;&quot; title=&quot;MR&quot; maritalstatus=&quot;1&quot; employer=&quot;&quot;&gt;&lt;address zip=&quot;15136&quot; city=&quot;MC KEES ROCKS&quot; state=&quot;PA&quot; address1=&quot;&quot; address2=&quot;123 Main Street&quot;/&gt;&lt;contactinfo homephone=&quot;&quot; officephone=&quot;&quot; officeext=&quot;&quot; otherphone=&quot;&quot; othertype=&quot;&quot; preferredcommunicationfid=&quot;&quot; confidentialcommunicationfid=&quot;&quot; communicationnote=&quot;&quot; email=&quot;&quot; emailverificationstatus=&quot;0&quot;/&gt;&lt;/patient&gt;&lt;/patientlist&gt;&lt;resppartylist&gt;&lt;respparty name=&quot;SELF&quot; accttype=&quot;4&quot;/&gt;&lt;/resppartylist&gt;&lt;/ppmdmsg&gt;';
  
  $headers = array();
  $headers[] = 'Content-Type: text/xml';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST,&quot;POST&quot;);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);
  curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
  //Send the request
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
  $response = curl_exec($ch);
  curl_close($ch);
  $array_data = json_decode(json_encode(simplexml_load_string($response)), true);
  print_r('&lt;pre&gt;');
  print_r($array_data);
  print_r('&lt;/pre&gt;');
  </code></pre>
  <p>The response is as following:</p>
  <pre><code>Array
  (
      [Results] =&gt; Array
          (
          )
  
      [Error] =&gt; Array
          (
              [Fault] =&gt; Array
                  (
                      [faultcode] =&gt; Client
                      [faultstring] =&gt; Client Error
                      [detail] =&gt; Array
                          (
                              [code] =&gt; 400
                              [description] =&gt; Bad Request: XML cannot be parsed
                              [extrainfo] =&gt; Bad Request: XML cannot be parsed. Check the XML you are sending to make sure it can be parsed.
                          )
  
                  )
  
          )
  
  )
  </code></pre>