title: HTTP client Cakephp 3 ignores json body
body: <p>I'm currently writing a RESTful API in Cakephp 3 whereby I need to test a POST operation through <a href="http://host.com/api/pictures" rel="nofollow noreferrer">http://host.com/api/pictures</a>. The code for the test:</p>
  
  <pre><code>&lt;?php
  namespace App\Test\TestCase\Controller;
  
  use App\Controller\Api\UsersController;
  use Cake\TestSuite\IntegrationTestCase;
  use Cake\Network\Http\Client;
  use Cake\Network\Http\FormData;
  
  class ApiPicturesControllerTest extends IntegrationTestCase{
      public $fixtures = [
          'app.users',
          'app.comments',
          'app.albums',
          'app.users_albums'
      ];
  
      public function testAdd(){
           // $data = new FormData();
           $accessToken ='eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjksImV4cCI6MTQ1NzYyOTU3NH0.NnjXWEQCno3PUiwHhnUCBjiknR-NlmT42oPLA5KhuYo';
           $http = new Client([
                'headers' =&gt; ['Authorization' =&gt; 'Bearer ' . $accessToken, 'Content-Type' =&gt; 'application/json']
           ]);
          $data = [
              "album_id" =&gt; 1,
              "link" =&gt; "http://www.google.com",
              "description" =&gt; "testtesttest",
              "favorite" =&gt; true
          ];
          $result = $http-&gt;post('http://vecto.app/api/pictures/add.json', $data, ['type'=&gt;'json']);
  
          // $this-&gt;assertResponseOk();
          // debug($result);
    }
  }
  </code></pre>
  
  <p>When I try to debug the result I get a 'cannot add or update child row' while I'm sure the responding id does exists 
  (the fixtures does have the id's too). Additionally, the log indicates that it only tries to insert the create/update rows. Therefore, I'm pretty sure the data is ignored but however I can't find a solution. I already tried different combination of headers like only application/json for Accept, application/json for Content-Type etc. I'm using the CRUD plugin for Cakephp to pass the data to an add function. <br><br>
  <strong>Postman output</strong>
  <a href="https://i.stack.imgur.com/MgWEu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MgWEu.png" alt="Postman output"></a></p>
  
  <p>Furthermore, I tried the Postman Chrome plugin to save the data and that actually does work. Does anyone know what I'm doing wrong in the test?</p>