title: POST request in laravel 5 with token via PhpUnit?
body: <p>I am trying to test my Laravel APIs using phpunit and I am using the <code>$this-&gt;call();</code> method to perform calls and see if they are working fine.</p>
  
  <p>I am also JWT for authentication and hence have to pass my token with it. Simple GET requests are easy:</p>
  
  <pre><code>$response = $this-&gt;call('GET', 'users?token=' . $this-&gt;token);
  </code></pre>
  
  <p>But when I need to create a new user or any resource for that matter, I am trying to do:</p>
  
  <pre><code>$response = $this-&gt;call('POST', 'users/?token=' . $this-&gt;token, $user);
  </code></pre>
  
  <p>But it is giving me a redirect like so:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;\n
  &lt;html&gt;\n
      &lt;head&gt;\n
          &lt;meta charset="UTF-8" /&gt;\n
          &lt;meta http-equiv="refresh" content="1;url=http://localhost" /&gt;\n
  \n
          &lt;title&gt;Redirecting to http://localhost&lt;/title&gt;\n
      &lt;/head&gt;\n
      &lt;body&gt;\n
          Redirecting to &lt;a href="http://localhost"&gt;http://localhost&lt;/a&gt;.\n
      &lt;/body&gt;\n
  &lt;/html&gt;
  </code></pre>
  
  <p>Now when I did some digging, I came across this:</p>
  
  <p><a href="https://stackoverflow.com/questions/30297607/redirect-302-on-laravel-post-request">Redirect 302 on Laravel POST request</a></p>
  
  <p>And the API for the call method looks like so:</p>
  
  <pre><code>$response = $this-&gt;call($method, $uri, $parameters, $cookies, $files, $server, $content);
  </code></pre>
  
  <p>So I tried this:</p>
  
  <pre><code>$response = $this-&gt;call('POST', 'users/?token=' . $this-&gt;token, $user, [], [], [], ['Content-Type' =&gt; 'application/x-www-form-urlencoded']);
  </code></pre>
  
  <p>But I am still getting a redirect. What am I missing?</p>