我在symfony中創建一個webservice,我試圖對數據庫進行一次post調用。在使用郵遞員發帖時,我得到的錯誤301永久移動。 這是我的控制器代碼與發佈json到數據庫有問題 - 301永久移動symfony
/**
* @Route("/post/influ/")
*/
public function postAction(Request $request)
{
$data = new User;
$firstname = $request->get('firstname');
$lastname = $request->get('lastname');
$username = $request->get('username');
$gender = $request->get('gender');
$email = $request->get('email');
$country = $request->get('country');
$state = $request->get('state');
$password = $request->get('password');
$retypePassword = $request->get('retypePassword');
if(empty($firstname) || empty($lastname))
{
return new View("NULL VALUES ARE NOT ALLOWED", Response::HTTP_NOT_ACCEPTABLE);
}
$data->setFirstname($firstname);
$data->setLastname($lastname);
$data->setUsername($username);
$data->setGender($gender);
$data->setEmail($email);
$data->setCountry($country);
$data->setState($state);
$data->setPassword($password);
$data->setRetypePassword($retypePassword);
$em = $this->getDoctrine()->getManager();
$em->persist($data);
$em->flush();
return (" Added Successfully", Response::HTTP_OK);
}
這是我使用的郵遞員,但返回301發佈到數據庫中的JSON永久移動作爲響應
{
"id": 3,
"firstname": "xyz",
"lastname": "xyz",
"username": "hello",
"gender": "Male",
"email": "[email protected]",
"country": "MyContry",
"state": "MyState",
"password": "password",
"retype_password": "password"
}
這是我作出的網址張貼到
http://localhost:88/HelloApi/web/app_dev.php/post/influ
請什麼可能是錯誤的。謝謝