2
votes

I have a REST API done in Symfony2 with FOSRestBundle Globally, it works but.. I have a route like this

/api/mymethod/{param}

with the implicit .{_format} When my param has no dot inside,

.../mymethod/toto.json

it works. But if it has a dot, I'm getting the message

ERROR - Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /api/mymethod/toto.com.json"" at C:\outils\wamp64\www\spapiDev\app\cache\dev\classes.php line 2100

Where am I wrong? Is there a workaround?

1

1 Answers

0
votes

First of all, you should avoid using dots in your route parameters. Try to use a slug instead.

But, to achieve what you want, you can add a regex to your param like this:

# ..
requirements:
    param: .+

You can check this cookbook article for more details.