title: PostAsJsonAsync POST variables don't arrive at Flight PHP REST server
body: <p>I have a Flight PHP REST server set up.
  At 1 end point it expects POST data and based on one of the POST data it retrieves some data from the database and returns it as JSON.</p>
  
  <p>When I use the Postman REST extension in Chrome I see the correct result. But when I do the call using my C# application the returned json is null because the $_POST seems empty.</p>
  
  <p>This is my Flight index.php:</p>
  
  <pre><code>Flight::route('POST /getText', function(){  
    // Create a new report class:
    $reportText = new ReportText;
    $theText = $reportText-&gt;ParsePost($_POST);
    if ($theText == null)
    {
      echo null;
    }
    else
    {
      echo json_encode($theText);
    }        
  });
  </code></pre>
  
  <p>This is my ParsePost:</p>
  
  <pre><code>public function ParsePost($PostDictionary)
  {
      $textArray = null;
      foreach ($PostDictionary as $key =&gt; $value)
      {
          if (!empty($value))
          {
              list($tmp, $id) = explode("_", $key);
              $text = $this-&gt;geFooWithText($id);
              $textArray[$key] = "bar";
          }
      }
  
      return $textArray;
  }
  </code></pre>
  
  <p>This is my C# part:</p>
  
  <pre><code>private static async Task RunAsyncPost(string requestUri)
  {
      using (var client = new HttpClient())
      {
          // Send HTTP requests
          client.BaseAddress = new Uri("myUrl");
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
          try
          {
              // HTTP POST
              var response = await client.PostAsJsonAsync(requestUri, new { question_8 = "foo", question_9 = "bar" });
              response.EnsureSuccessStatusCode(); // Throw if not a success code.
              if (response.IsSuccessStatusCode)
              {
                  var json = await response.Content.ReadAsStringAsync();
                  if (string.IsNullOrEmpty(json))
                  {
                      throw new ArgumentNullException("json", @"Response from the server is null");    
                  }
  
                  var dictionary = JsonConvert.DeserializeObject&lt;Dictionary&lt;string, string&gt;&gt;(json);
  
                  foreach (var kvp in dictionary)
                  {
                      Debug.WriteLine("Key: {0}, Value: {1}", kvp.Key, kvp.Value);
                  }
              }
          }
          catch (HttpRequestException e)
          {
              // Handle exception.
              Debug.WriteLine(e.ToString());
              throw;
          }
      }
  }
  </code></pre>
  
  <p>This is the response from Postman:</p>
  
  <pre><code>{
    "question_8": "foo",
    "question_9": "bar"
  }
  </code></pre>
  
  <p>It seems I'm missing something in my call using C#.</p>
  
  <p>[Update]</p>
  
  <p>In this post (<a href="https://stackoverflow.com/questions/26965520/unable-to-do-a-http-post-to-a-rest-service-passing-json-through-c-sharp">Unable to do a HTTP POST to a REST service passing json through C#</a>) the same problem seems to appear.
  Using Fiddler was suggested.</p>
  
  <p>Using Postman and x-www-form-urlencoded:</p>
  
  <pre><code>POST http://myHost/api/getText HTTP/1.1
  Host: myHost
  Connection: keep-alive
  Content-Length: 29
  Cache-Control: no-cache
  Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
  Content-Type: application/x-www-form-urlencoded
  Accept: */*
  Accept-Encoding: gzip,deflate
  Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
  
  question_8=foo&amp;question_9=bar
  </code></pre>
  
  <p>Using Postman and form-data:</p>
  
  <pre><code>POST http://myHost/api/getText HTTP/1.1
  Host: myHost
  Connection: keep-alive
  Content-Length: 244
  Cache-Control: no-cache
  Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
  User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
  Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryvb4wmaP4KooT6TFu
  Accept: */*
  Accept-Encoding: gzip,deflate
  Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
  
  ------WebKitFormBoundaryvb4wmaP4KooT6TFu
  Content-Disposition: form-data; name="question_8"
  
  foo
  ------WebKitFormBoundaryvb4wmaP4KooT6TFu
  Content-Disposition: form-data; name="question_9"
  
  bar
  ------WebKitFormBoundaryvb4wmaP4KooT6TFu--
  </code></pre>
  
  <p>Using my C#-application:</p>
  
  <pre><code>POST http://myHost/api/getText/ HTTP/1.1
  Accept: application/json
  Content-Type: application/json; charset=utf-8
  Host: myHost
  Content-Length: 50
  Expect: 100-continue
  Connection: Keep-Alive
  
  {"question_8":"foo","question_9":"bar"}
  </code></pre>
  
  <p>The C# application is sending it clearly in a different way.</p>