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
0
votes
1 answer

FOSRestBundle post many to one relation

I would like to know how to properly post data when Entity has another ManyToOne relation in FOSRestBundle. User entity has locale (locale_id): /** * @ORM\ManyToOne(targetEntity="Locale") * @ORM\JoinColumn(name="locale_id",…
undefinedman
  • 620
  • 1
  • 11
  • 25
0
votes
1 answer

Ajax post request with Symfony2 FosRestBundle and NelmioCorsBundle

I'm developing an API, I want it to work with ajax request in client side. I also am using Nelmio Cors and FOS Rest. AJAX GETs work fine. AJAX POST throws this error back to me (I'm testing with jQuery btw): ... exception: [{message: "Invalid json…
danielrvt
  • 10,177
  • 20
  • 80
  • 121
0
votes
1 answer

Return a 'raw' response with FOSRestBundle

I'm in a bit of a pickle and I hope one of the more advanced Symfony / FOSRestBundle users can help me out with this. FOSRestBundle returns responses as such: The…
SliceOfLife
  • 89
  • 2
  • 7
0
votes
0 answers

How to use custom HTTP methods in Symfony2 FOSRestBundle

I use FOSRestBundle for my RESTful API. Lets say I want to use some custom HTTP method for WebDav or something else. Lets say I want to implement imaginary FIRE method. How can I implement it in this bundle? I'd like to have fireResourceAction() in…
AdamZ
  • 1,901
  • 1
  • 12
  • 9
0
votes
0 answers

Populate doctrine entity using fos rest bundle in post request

I have the following action: /** * @param Agent $agent * @Post("/agents") * @ParamConverter(class="DnDRaHApiBundle:Agent") */ public function postAction(Agent $agent) { //return $request->request->all(); } But when I hit the url with a post…
danielrvt
  • 10,177
  • 20
  • 80
  • 121
0
votes
1 answer

Symfony2 FosRestBundle root api url

I've been looking at the FOS-Rest-Bundle documentation in order to develop an API of mine. The problem is that I would like the API to be under api/ and there doesn't seem to be any option to achieve this. Is there a way? how would I do this? Thanks
danielrvt
  • 10,177
  • 20
  • 80
  • 121
0
votes
1 answer

Symfony 2 Rest api

I created a simple REST service based on Symfony 2 and FriendsOfSymfony/FOSRestBundle. The GET request work well but I have a problem with POST. I used this tutorial: http://npmasters.com/2012/11/25/Symfony2-Rest-FOSRestBundle.html When I send…
Adam Michna
  • 169
  • 1
  • 7
0
votes
2 answers

fos rest custom get url in symfony2

I need to create a custom url in my rest api. I am using fos rest bundle. custom URL is like: http://myapi.com/api/v1/public/users/confirm?cd=.json I have tried: @GET("/users/confirm?cd={cd}") and when I run: php /app/console…
Ashish Awasthi
  • 1,484
  • 1
  • 19
  • 34
0
votes
0 answers

Unrecognized options "type" under "nelmio_api_doc.sandbox.authentication"

Having problem to call api form nelmio api doc, api work from Postman extension config.yml fos_rest: body_converter: enabled: true body_listener: decoders: json: fos_rest.decoder.json routing_loader: …
Avinash
  • 81
  • 2
  • 9
0
votes
1 answer

How can I use a DataTransformer transform with the FosRestBundle view layer

I've using a DataTransformer on my form to reverseTransform a decimal value send by the client into a Money/Money object. This works well as expected, however when I return the data to the client using the FosRestBundle view layer, I'm not sure how…
greg
  • 6,853
  • 15
  • 58
  • 71
0
votes
1 answer

FOSRest bundle not found route for action

I try to use FOSRestBundle but gets error: No route found for "GET /en/users" Here is controller action: public function getUsersAction() { return new Response('resting'); } Here is config in app/config/routin.yml: geekhub_main: resource:…
nowiko
  • 2,507
  • 6
  • 38
  • 82
0
votes
0 answers

Best Practices on namespaces : on Symfony, difference of perfs when using (sub)namespaces?

I'm building an API and I would ask something about using namespaces on a Symfony2 controller. Is there a real difference doing :
0
votes
0 answers

Symfony testing endpoint consumes JSON correctly

I have an API built in Symfony using the FOSRestBundle. I want to write a simple test to validate whether when I submit some JSON that the results get properly processed and the expected response gets returned. Working test code $user =…
Malachi
  • 33,142
  • 18
  • 63
  • 96
0
votes
1 answer

Exclude some attributes from relational entity RestBundle Symfony2

I want to exclude some attributes when I return an object with relations. For example, I have an entity Users and Album and I just want to expose the username when I get a list of Album. Is it possible ? Here is my Album entity :
Thibaud Grd
  • 13
  • 1
  • 2
0
votes
0 answers

Symfony 2.5 and FOSRestBundle: How to log in user

I want to programmatically log in an user using the FOSRestBundle (I am not using FOSUserBundle). It seems to work, but when I logged in successfully and try to access an secured endpoint, Symfony throws an AccessDeniedException. This is my…
Johannes Klauß
  • 10,676
  • 16
  • 68
  • 122