When i go to : http://mysite.com/web/app_dev.php/user/register
I am getting:
MethodNotAllowedHttpException: No route found for "GET /user/register": Method Not Allowed (Allow: POST)
Here is my code:
MainUserBundle_register:
pattern: /user/register/
defaults: { _controller: MainUserBundle:UserAuthWebService:register, _format:json}
requirements:
_method: POST
my controller is:
public function registerAction($email="test", $username="test", $password="test123")
{
//some code
}
Why?
You can restrict a route to only match a given HTTP method. In the code you posted the route will only match POST requests. You will need to allow POST and GET, or remove the requirement all together.
MainUserBundle_register:
pattern: /user/register/
defaults: { _controller: MainUserBundle:UserAuthWebService:register, _format:json}
requirements:
_method: POST|GET
http://symfony.com/doc/current/book/routing.html#adding-http-method-requirements
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With