1. You are sending a simple string "action=test" but you "must" send a JSON-formatted string.
2. Create a map and add "action" as the key and "test" as the value
3. Use the JSON-generator with the map and you get {"action":"test"}
4. In php decode the JSON to an array:
$jsonstring = file_get_contents("php://input");
$myarray = json_decode($jsonstring, true);
$action = $myarray["action"];
...