Search code examples
phprestsymfonyfosrestbundle

FOSRestBundle : Difference between RequestParam and QueryParam


I don't understand the difference between the @QueryParam et the @RequestParam annotation with FOSRestBundle (Example : https://symfony.com/doc/master/bundles/FOSRestBundle/param_fetcher_listener.html).

Do you have any mean to know which one I have to use to declare my API parameters?


Solution

  • Depends on what you want to achieve with your API endpoints. Basically QueryParam represents a parameter that must be present in GET data (so we're talking about query string parameters) while RequestParam represents a parameter that must be present in POST or PUT data (which means parameters in the body of the request).