Custom operation route "Not Found" error
See original GitHub issueMy API Resource:
namespace AppBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* @ApiResource(
* collectionOperations={
* "list"={"route_name"="campaign_list"}
* }
* )
* @ORM\Entity
*/
class Campaign {
...
}
My custom action:
namespace AppBundle\Action;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\JsonResponse;
use AppBundle\Entity\Campaign;
class CampaignList
{
/**
* @Route(
* name="campaign_list",
* path="/list",
* defaults={
* "_api_resource_class"=Campaign::class,
* "_api_collection_operation_name"="list"
* },
*
* )
* @Method("GET")
*/
public function __invoke()
{
return new JsonResponse(['test'=>'test']);
}
}
My routing:
api:
resource: 'api'
prefix: /api
type: 'api_platform'
Then I try to send request, and got 404 error:

Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Custom Routes not working - 404 not found
I'm trying to create a custom route. The must be in this format: http://localhost:8000/home-back-to-school but instead I get a 404 not found ......
Read more >Magenot 2.4 custom routes does not working. All time i get ...
When I put this mageplaza module in my app/code directory all works fine. I see one difference between the Magepaza module router and...
Read more >Routing to controller actions in ASP.NET Core
Learn how ASP.NET Core MVC uses Routing Middleware to match URLs of incoming requests and map them to actions.
Read more >Router tutorial: tour of heroes
Any other URL causes the router to throw an error and crash the app. ... A wildcard route can navigate to a custom...
Read more >My Custom Route isn't working
I have started something, not entirely sure it's a plugin yet. ... The error says “{“code”:”rest_no_route”,”message”:”No route was found matching the URL ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mitalcoi yes, the route isn’t matched correctly because of itemOperation regex (regex is too open - matches everything).
quick solution: move “app” routing configuration before “api_platform” routing cfg so your custom routes will be matched before the generated (from api_platform) ones
I’ve just applied your PATCH to fresh instance of api-platform, and routes are rendered OK (only difference is that I used
_api_collection_operation_name
instead of_api_item_operation_name
from your PATCH) until I try to send smth to this route: