3

I created a shopware6 plugin which includes a frontend custom route which should be able to receive POST requests from ExactOnline.

But when I make some tests with Postman, I receive "405 Method Not allowed". Here is my controller :

<?php

namespace Emakers\TransmissionPlugin\Controller;

//use Emakers\TransmissionPlugin\Controller\Frontend\Services\ExactRequirements;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Controller\StorefrontController;
use Symfony\Component\Routing\Annotation\Route;


/**
 * @RouteScope(scopes={"storefront"})
 */
class AccountsController extends StorefrontController
{

    /**
     * @Route("/accounts", name="frontend.accounts", options={"seo"="false"}, methods={"POST"})
     */
    public function accounts()
    {
        die('ok boy');
        $file    = 'custom/plugins/TransmissionPlugin/Resources/webhooks/accountWebhook.txt';

        }

    }

When I replace the methods={"POST"} by methods={"GET"}, the same test request returns "ok boy" which is normal.

I had already created a plugin like this in Shopware5 and GET and POST requests were already working without doing anything special.

How to make POST requests ALLOW in my case on Shopware6?

Thanks !

1 Answer 1

5

You have limited the route to POST. When you call it from another Method then POST, it will result in Method not allowed error. Maybe you want to whitelist both GET and POST?

So change it to methods={"GET", "POST"}

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.