0

i have a rest api, based on symfony 2.3. It works nice on debug mode but if i switch to prod env, i always get a 501 response error with this message "This method may not be used." on DELETE Http request (get works fine).

I check the configuration, got:

config.yml:

http_method_override => true

Here is my routing:

test_delete:
    path:   /categories
    defaults: { _controller: OMGAPIBundle:GET\GetCategory:deleteTest }
    requirements:
        _method:  DELETE

And my controller:

public function deleteTestAction(){
    return new Response(1);
}
MarcD
  • 314
  • 1
  • 8
  • are you working on port `80` ? – trrrrrrm Sep 17 '14 at 17:28
  • 1
    Not sure if it will help your profile but you should be using `methods: [DELETE]` instead of `requirements:_method: DELETE` to set the allowed/required method(s). – qooplmao Sep 17 '14 at 20:03
  • @Qoop i tried to replace requirements:_method: DELETE by methods: [DELETE] and even tried both :p nothing changed :s – MarcD Sep 17 '14 at 20:25
  • @ra_htial seems stupid, i don't even know where i should check that :p but we are using https so i'm not sure. – MarcD Sep 17 '14 at 20:29
  • Are you routing your controller right? If you change the request to GET, does it works? – Facundo Fasciolo Sep 17 '14 at 22:03
  • if i'm not mistaken it's the `https` can you try to run it over `http` ? – trrrrrrm Sep 18 '14 at 05:30
  • I think i found it, this is a pound bad configuration: http://www.apsis.ch/pound/ i'll check that. @facundoFasciolo yes, POST and GET works fine. – MarcD Sep 18 '14 at 08:44

2 Answers2

0

Try this:

test_delete:
    pattern: /categories
    defaults: { _controller: OMGAPIBundle:YourControllerName:deleteTest }
    methods: [DELETE]

Obviusly, your controller must be written like this:

class YourControllerNameController{
    ...
    public function deleteTestAction(){
        return new Response(1);
    }
    ...
}

And be sure that you are sending a DELETE request...

Facundo Fasciolo
  • 452
  • 4
  • 15
0

This was a bad pound configuration. It works now :)

=> http://www.apsis.ch/pound/

MarcD
  • 314
  • 1
  • 8