# SW 6.6 admin Ajax request to custom controller does not work anymore

**URL:** <https://forum.shopware.com/t/sw-6-6-admin-ajax-request-to-custom-controller-does-not-work-anymore/103684>\
**Category:** Shopware 6 (English)\
**Tags:** programming\
**Created:** [12. April 2024 um 09:28 UTC](https://forum.shopware.com/t/sw-6-6-admin-ajax-request-to-custom-controller-does-not-work-anymore/103684 "2024-04-12T09:28:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miro](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@miro](https://forum.shopware.com/u/miro)\
**Post date:** [12. April 2024 um 09:28 UTC](https://forum.shopware.com/t/sw-6-6-admin-ajax-request-to-custom-controller-does-not-work-anymore/103684/1 "2024-04-12T09:28:44Z")

</div>

Hi to all!

I have a plugin where in an admin template I create an Ajax call to custom controller to get some data.  
After the upgrade to v6.6 the call returns 404 - no route found. Is still possible to do this and if yes where I can find example how to do it? All links I found are for the Storefront.

Regards!

---

<div class="post-metadata">

**Author:** ![miro](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@miro](https://forum.shopware.com/u/miro)\
**Post date:** [12. April 2024 um 09:36 UTC](https://forum.shopware.com/t/sw-6-6-admin-ajax-request-to-custom-controller-does-not-work-anymore/103684/2 "2024-04-12T09:36:54Z")

</div>

Looks like I made it, just replace in-comment route with the new syntax:

#[Route(path: ‚the\_path‘, name: ‚the\_api\_name‘, defaults: [‚auth\_required‘ =\> false, ‚XmlHttpRequest‘ =\> true], methods: [‚POST‘, ‚GET‘])]

---

<div class="post-metadata">

**Author:** ![waf-live95](https://avatars.discourse-cdn.com/v4/letter/w/54ee81/32.png) [@waf-live95](https://forum.shopware.com/u/waf-live95)\
**Post date:** [17. April 2024 um 09:12 UTC](https://forum.shopware.com/t/sw-6-6-admin-ajax-request-to-custom-controller-does-not-work-anymore/103684/3 "2024-04-17T09:12:58Z")

</div>

I have teh same issue.  
Can u show me your Controller please ?

this is my Controller

```auto
use Shopware\Core\Framework\Context;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\HttpFoundation\JsonResponse;

#[Route(defaults: ['_routeScope' => ['api']])]
class TestController extends AbstractController
{
    private $services;

    public function __construct(iterable $services)
    {
        $this->services = $services;
    }

    #[Route(path: '/api/test/test-productioncheck', name: 'api.action.test.test-productioncheck', defaults: ['auth_required' => false, 'XmlHttpRequest' => true], methods: ["GET"])]
    public function index(Request $request, Context $context)
    {
        $result = [];

        foreach ($this->services as $checkService) {
            $result = array_merge($result, $checkService->getCheckResult());
        }

        return new JsonResponse([
            'data' => $result,
        ]);
    }
}

```

I want to display the data in the admin but I get a 404 error and the data are not displayed @miro

---

<div class="post-metadata">

**Author:** ![miro](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@miro](https://forum.shopware.com/u/miro)\
**Post date:** [17. April 2024 um 11:11 UTC](https://forum.shopware.com/t/sw-6-6-admin-ajax-request-to-custom-controller-does-not-work-anymore/103684/4 "2024-04-17T11:11:32Z")

</div>

Your code looks ok, mine looks like this:

```auto
<?php declare(strict_types=1);

namespace Swag\directory_name\Administration\Controller;

// lot of use classes next

#[Route(defaults: ['_routeScope' => ['api']])]
/**
 * @author
 */
class OrderController extends AbstractController
{
   // some variables
   // then the constructor with lot of parameters in it
   // and one of my public methods looking like this:
   #[Route(path: '/api/company_name/check_order', name: 'api.action.company_name.check_order', defaults: ['auth_required' => false, 'XmlHttpRequest' => true], methods: ['POST', 'GET'])]
   /**
    * description here, then legacy route
    * @Route("/api/company_name/check_order", name="api.action.company_name.check_order", defaults={"auth_required"=false, "XmlHttpRequest"=true}, methods={"GET", "POST"})
     * 
     * @param Request $request
     * @param Context $context
     * 
     * @return JsonResponse
     */
   public function checkForOrder(Request $request, Context $context)
   {
      ...
      // and return JsonResponse at the end.
   }
}

```

That is all. Tested on version 6.6.1.0. I hope this can help you!

Regards!

PS - may be the only difference is you are using „-“ in the route, I use „\_“. I am not sure your is wrong, but you can try to replace it.
