title: problems with php POST - POST body is empty in login request
body: <p>I am currently working on an APP that sends a post request to a server to login. The backend developer of my team is a bit slow so I thought why wouldn't I just set up some mock urls for testing the app.
   I got a php file for the login which should return me a session when I enter correct data. Unfortunately I am stuck trying to get the JSON i post into some variables.</p>
  
  <p>In fact, i don't see any data i receive. I've tried to use vardump on <code>$_POST</code>, <code>$HTTP_RAW_POST_DATA</code> as wel as <code>file_get_contents("php://input")</code>. I tried to decode the latter two with <code>json_decode</code>.
   Some give me <code>String(0) ""</code> others give me <code>NULL</code>. In some cases i just got nothing.</p>
  
  <p>Using retrofit i send a request to <strong>/login</strong> with a body of </p>
  
  <pre><code>{
      "password":"password",
      "username":"Marcel"
   }
  </code></pre>
  
  <p>However when what i get as return is nothing. The my php code is only getting the and returning a json object with a session token</p>
  
  <pre><code>if(!empty($_POST["username"]) &amp;&amp; !empty($_POST["password"])){
      $id= array('SESSION_ID' =&gt; 'random_session_token_0015');
      echo json_encode($id);
  }
  </code></pre>
  
  <p>This code example does not give me any return. Using <code>print_r($_POST);</code> i will get an empty array like <code>array()</code>.</p>
  
  <pre><code>$json = file_get_contents('php://input');
  $object = json_decode($json);
  var_dump($object);
  </code></pre>
  
  <p>This code example does give me any return, but it is <strong>NULL</strong>. <code>$HTTP_RAW_POST_DATA</code> had the same result as the latter example.</p>
  
  <p>I'm quite stuck in this problem, anyone there to help?</p>
  
  <p>ps. aks if you need more info</p>
  
  <p><a href="https://i.stack.imgur.com/i646v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i646v.png" alt="Postman interface"></a></p>