Questions tagged [fosrestbundle]

A Symfony 2 plugin by FriendsOfSymfony (FOS) which provides various tools to rapidly develop RESTful API's with Symfony 2.

A Symfony 2 bundle by FriendsOfSymfony (FOS) which provides various tools to rapidly developer RESTful API's with Symfony 2.

Its features include:

  • A View layer to enable output and format agnostic Controllers
  • A custom route loader to generate url's following REST conventions
  • Accept header format negotiation including handling for custom mime types
  • RESTful decoding of HTTP request body and Accept headers
  • Exception controller for sending appropriate HTTP status codes

Links:

803 questions
6
votes
1 answer

accessing to /api methods in oauth2 server

Im trying to create an oauth2 server based on FOSOauthServerBundle, FOSRestBundle and FOSUserBundle. I created a demo application to test the my oauth-server and it failed receiving the data via the GET reguest (received 401 error '…
user1976651
  • 61
  • 1
  • 2
5
votes
1 answer

Symfony (3.4.2) - Error: Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private

I'm on an api project using FOSRestBundle on Symfony 3.4 and have some error when I want to use my own error messages. It says me: Controller "fos_rest.exception.twig_controller" cannot be fetched from the container because it is private. Did you…
ScoobyDam
  • 379
  • 3
  • 13
5
votes
1 answer

Symfony 3 Constraint validation Date or Datetime

I try to validate a date (or a datetime) with the validation of a form into Symfony (3.2). I'm using FOSRestBundle to use the json from request (because i try to develop my personnal API) But i've try a lot of format: 2017-04-09 17-04-09 for…
Fabrice
  • 105
  • 2
  • 7
5
votes
1 answer

Handling POST requests with Symofny Forms in FOSRestBundle

It's not clear to me how I should use the Symfony Form Component with FOSRestBundle for POST endpoints that I use to create resources. Here is what I've got in my POST controller action: //GuestController.php public function cpostAction(Request…
luqo33
  • 8,001
  • 16
  • 54
  • 107
5
votes
1 answer

symfony/FOSRestBundle : empty JSON response (using the symfony embodied serializer)

I'm learning to build API with symfony (using FOSRestBundle). I'm following a french tutorial. Obviously, I first try to write the code by myself but even with a copy/paste, it keeps get me empty JSON array when I do a GET request to the appropriate…
5
votes
1 answer

How to properly do a REST API POST call using FOSRest and Symfony 3.0

For an API I'm currently building I'd like to be able to send a request with a JSON body with the following content {"title": "foo"} to create a new database record for an Entity called Project. I made a controller which subclasses…
bmeulmeester
  • 1,117
  • 12
  • 26
5
votes
2 answers

How to exclude an api route from symfony2 firewall based on method

So i am building a symfony2 api using fosrestbundle fosuserbundle and LexikJWTAuthenticationBundle and when i want to acces to /api/users.json to post a new user i get a 401 error Bad Credentials. i tried to add a line in access control this way : -…
5
votes
1 answer

Nelmio Api Doc Bundle: Documentating required Parameters

I am currently working with the NelmioApiDocBundle, with which I am not very familiar yet. The API I am writing has to provide a route to change the password of a specific user. The documentation should state, that for changing the password both the…
5
votes
2 answers

Symfony2 App with RESTful authentication, using FOSRestBundle and FOSUserBundle

I'm making REST API for my JS driven app. During login, the login form is submitted via AJAX to url /rest/login of my API. If the login is succesful, it returns 204 If it fails, it returns 401 While I have separated firewalls for the API and the…
5
votes
0 answers

FOSRestBundle - POST went fine, but when use PUT/PATCH $request is null

I was following this tutorial http://welcometothebundle.com/symfony2-rest-api-the-best-way-part-3/ and then I've added a new entity, Author. Using GET, POST and DELETE everything goes as expected, but when using PUT or PATCH I get as…
5
votes
0 answers

Symfony2 - FOS REST Bundle - QueryParam complex constraint

In the documentation is said that we can apply a complex constraint on a query param like: @QueryParam( array=true, name="filters", requirements=@MyComplexConstraint, description="List of complex filters" ) taken from…
Stev
  • 1,062
  • 11
  • 23
5
votes
1 answer

How to handle submitted array of json with fosrest bundle and nemio api doc bundle

I have a controller in my Rest API that expects an array of json (in POST) { data: [ { name: "marc" }, { name: "john" } ] } Submitted data are then…
debugall
  • 310
  • 2
  • 11
5
votes
3 answers

Symfony 2 - FOSUserBundle - how to integrate in API

I work on a new Symfony 2 project. I'm learning this framework at the same time. For the user management, I use the bundle FOSUserBundle. My project works very well, I can login, register, logout and all other commands available. The thing is that I…
manonthemoon
  • 2,611
  • 8
  • 26
  • 40
5
votes
1 answer

JMSSerializer and FOSRestBundle - Annotations not working. "Does not exist"

I am trying to use ExclusionPolicy however I keep getting an "Annotation does not exist, or could not be auto-loaded" error. Here is the exact error being thrown out: [Semantical Error] The annotation …
5
votes
1 answer

How to work correctly with Forms, FOS Rest Bundle and many to many relations in Symfony2

I'm working with Symfony2 Forms and FOSRestBundle. I'm trying to save in the database, an entity with a many to many relationship. I create a Form with a collection field (http://symfony.com/doc/master/cookbook/form/form_collections.html) like…
escrichov
  • 559
  • 2
  • 6
  • 14