-1

Currently, I am updating the system running on the existing Symfony 2.3 (currently 3.0.9), and checking the operation.
When I tried to change the state of an item to the selected state, I got an error.
Do you have any advice for determining the case?

Error Code

No route found for "POST /admin/hq/article/3999/articleStatus": 
Method Not Allowed (Allow: PUT)

Code

ArticleController.php

    /**
     * Article status change
     *
     * @Method("PUT")
     * @Route("/article/{ids}/articleStatus")
     * @Secure(roles="ROLE_HQ_MANAGE")
     */
    public function updateArticleStatusAction(Request $request, $ids)
    {
        return parent::updateArticleStatusAction($request, $ids);
    }

Version

CentOS 6.7
PHP 5.6
Symfony3.0.9

youplus
  • 71
  • 1
  • 9

2 Answers2

0

I'm guessing you are using a web browser to submit a form and the action goes to /admin/hq/article/3999/articleStatus which only allows PUT operations (because of the @Method("PUT") annotation). Wheras submitting a form with a browser is a POST operation. Change that line to @Method("POST") and you should be fine.

craigh
  • 1,909
  • 1
  • 11
  • 24
  • the only possible reason for downvoting might be, that *some* api might be talking with this endpoint and using PUT requests, which this answer would break. I'd be a bit careful ... – Jakumi Jan 03 '21 at 12:51
-1

Go vendor/symfony/http-foundation/Request.php and check line 80 in Symfony 6.2 and change this value from false to true

protected static $httpMethodParameterOverride = true;
Kmk
  • 1
  • 1
  • Editing code in the vendor directory directly is very bad practice! You should never do this unless you're planning on creating a patch. Instead `config/packages/framework.yml` should be updated by adding `framework.http_method_override: true` – E S Mar 01 '23 at 17:28