title: PHP - curl post view request body (parameters)
body: <p>I get an error response for missing parameter when posting cURL POST method, 
  I'm adding an array of parameters to CURLOPT_POSTFIELDS the following way:</p>
  
  <pre><code>$service = "AutoInsuranceFormPostService";
  $method = "autoInsurancePublisherFormPost";
  $userAgent = "Mozilla%2F5.0+%28Linux%3B+Android+4.4.4%3B+Z752C+Build%2FKTU84P%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F36.0.1985.135+Mobile+Safari%2F537.36";
  $payload = $encodedPayLoad;
  
  $parameters = array (
      'service' =&gt; $service,
      'method' =&gt; $method,
      'UserAgent' =&gt; $userAgent,
      'payload' =&gt; $payload
  );
  </code></pre>
  
  <p>With:</p>
  
  <pre><code>curl_setopt($ch,CURLOPT_POSTFIELDS,$parameters);
  </code></pre>
  
  <p>Since the response is saying missing parameter "service", I figured I need to debug the request body. 
  I managed to get the headers with:</p>
  
  <pre><code>curl_getinfo($ch)
  </code></pre>
  
  <p>I also attempted to use:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_VERBOSE, true);
  </code></pre>
  
  <p>But unfortunately in both cases I only got the headers and not the body (the parameters values). </p>
  
  <p>Full curl execution function:</p>
  
  <pre><code>function openurl($url, $postvars) {
  
  $ch=curl_init();
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  $verbose = fopen('php://temp', 'w+');
  curl_setopt($ch, CURLOPT_STDERR, $verbose);
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_POST, TRUE);
  curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch,CURLOPT_TIMEOUT, '3');
  
  $result = curl_exec($ch);
  
  rewind($verbose);
  $verboseLog = stream_get_contents($verbose);
  echo "Verbose information:\n&lt;pre&gt;", htmlspecialchars($verboseLog), "&lt;/pre&gt;\n";
  return $result;
  }
  </code></pre>
  
  <p>Verbos information:</p>
  
  <pre><code>Content-Length: 6659
  Expect: 100-continue
  Content-Type: application/x-www-form-urlencoded; boundary=------------------------45b2d9f6776306b0
  
  &lt; HTTP/1.1 100 Continue
  &lt; HTTP/1.1 200 OK
  &lt; Date: Thu, 12 Jul 2018 16:32:52 GMT
  &lt; Server: Apache
  &lt; Cache-Control: public
  &lt; ORIGIN: S_CACHE
  &lt; Vary: User-Agent,Accept-Encoding
  &lt; Set-Cookie: _qs_origin=s-cache; path=/;
  &lt; Set-Cookie: _qs_deviceType=; path=/;
  &lt; Content-Length: 141
  &lt; Content-Type: application/json;charset=ISO-8859-1
  &lt; 
  </code></pre>
  
  <p>This output is useless for me since I cannot see how the parameters were sent and those cannot fix their format. </p>
  
  <p>The response I get is:</p>
  
  <pre><code>{"Status":"Fail","StatusCode":"400","ResponseMessage":"\"service\" parameter empty! || \"method\" parameter empty! ","SkipMatchingFlag":"No"}
  </code></pre>
  
  <p>I have been searching for a solution all day long, I've seen a ton of answers on "How to see the RESPONSE body", and "How to see the request HEADERS".
  <br> But none for "How to see the request body", so any help would be much appreciated,
  <br>
  Best regards. </p>