Solved the issue by actually receiving the body as json format in my php and sending it back in the same format
$jsonData = file_get_contents('php://input');
$data = json_decode($jsonData, true);
if ($data !== null) {
$name = $data['username'];
echo json_encode($name);
}
else {
echo json_encode('e no work');
}