title: How do I get the body of SENT data with Guzzle PHP?
body: <p>I am using Guzzle (v6.1.1) in PHP to make a POST request to a server. It works fine. I am adding some logging functions to log what was sent and received and I can't figure out how to get the data that Guzzle sent to the server. I can get the response just fine, but how do I get the <strong>sent</strong> data? (Which would be the JSON string.)</p>
  
  <p>Here is the relevant portion of my code:</p>
  
  <pre><code>$client = new GuzzleHttp\Client(['base_uri' =&gt; $serviceUrlPayments ]);
      try {
         $response = $client-&gt;request('POST', 'Charge', [
              'auth' =&gt; [$securenetId, $secureKey],
              'json' =&gt; [     "amount" =&gt; $amount,
                              "paymentVaultToken" =&gt; array(
                                      "customerId" =&gt; $customerId,
                                      "paymentMethodId" =&gt; $token,
                                      "publicKey" =&gt; $publicKey
                                      ),
                              "extendedInformation" =&gt; array(
                                      "typeOfGoods" =&gt; $typeOfGoods,
                                      "userDefinedFields" =&gt; $udfs,
                                      "notes" =&gt; $Notes
                                      ),
                              'developerApplication'=&gt; $developerApplication 
              ]
      ]);
  
      } catch (ServerErrorResponseException $e) {
          echo (string) $e-&gt;getResponse()-&gt;getBody();
      }
  
  
      echo $response-&gt;getBody(); // THIS CORRECTLY SHOWS THE SERVER RESPONSE
      echo $client-&gt;getBody();           // This doesn't work
      echo $client-&gt;request-&gt;getBody();  // nor does this
  </code></pre>
  
  <p>Any help would be appreciated. I did try to look in Guzzle sourcecode for a function similar to getBody() that would work with the request, but I'm not a PHP expert so I didn't come up with anything helpful. I also searched Google a lot but found only people talking about getting the response back from the server, which I have no trouble with. </p>