title: PHP CURL Using POST Raw JSON Data
body: <p>I am working with PHP curl for post, for some reason I couldn't post the form successfully. </p>
  
  <pre><code>$ch = curl_init();
  $headers = [
              'x-api-key: XXXXXX',
              'Content-Type: text/plain'
          ];
  $postData = array (
      'data1: value1',
      'data2: value2'
  );
  curl_setopt($ch, CURLOPT_URL,"XXXXXX");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);           
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
  $server_output = curl_exec ($ch);
  </code></pre>
  
  <p>When I try using the same in post it works, but not with PHP.</p>
  
  <pre><code>var_dump($server_output) ==&gt; string(67) ""require data1 and data2 or check the post parameters""
  var_dump(curl_error($ch)) ==&gt; string(0) ""
  </code></pre>