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

Symfony2 REST API - Partial update

I'm building a REST API with FOSRestBundle in Symfony2. I'm using forms to create and update entities with Doctrine2. Everything works fine if I send all form fields. Example: {"first_name":"Pi","last_name":"Wi"} The person is inserted fine but now…
Pi Wi
  • 1,076
  • 1
  • 11
  • 20
4
votes
4 answers

FOSRestBundle: show my custom exception message

I'm trying to add a custom control of exceptions in FOSRestBundle but it seems to ignore my custom messages (the status code of the response is ok). I have: throw new HttpException(404, "User {$id} not found"); But get this json response: { …
K. Weber
  • 2,643
  • 5
  • 45
  • 77
4
votes
1 answer

How can I serve HTML and JSON requests from the same route, using Symfony 2 and FOSRestBundle, using headers in addition to the _format?

I am attempting to serve content in both html and json formats (I also want to eventually allow for xml as well) using Symfony and the FOSRestBundle (ver. 1.3). I have been successful at serving different content for routes using the _format…
Sean Quinn
  • 2,131
  • 1
  • 18
  • 48
4
votes
0 answers

Jquery ajax 'patch' doesn't seem to be sending data

I have the following javascript code... function editShipment(){ var method = "PATCH"; var serializedData = $form.serialize(); $.ajax({ type: "PATCH", url: Routing.generate('api_1_shipment_patch_shipment', {api_key: API_KEY,…
Mark Dalby
  • 61
  • 1
  • 6
4
votes
2 answers

JSON Root Name in Serialized Entity

I'm using FOSRestBundle and JMSSerializerBundle to output JSON data to be consumed by an ember application. I would like to use the built-in adapters of ember-data and the JSON format that is expected has to have a root name. My current JSON is as…
Dan
  • 876
  • 5
  • 15
4
votes
1 answer

How to get groups working for JMSSerializerBundle and FOSRestBundle?

I am trying to set up different groups to achieve different types of serialization of my entities depending on the context. My config looks like this: My\FooBundle\Entity\Asset: exclusion_policy: ALL access_type: public_method …
k0pernikus
  • 60,309
  • 67
  • 216
  • 347
4
votes
1 answer

FOSRestBundle: ExceptionController not triggered

config.yml: twig: debug: %kernel.debug% strict_variables: %kernel.debug% exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction' fos_rest: routing_loader: default_format: json view: …
Roman Newaza
  • 11,405
  • 11
  • 58
  • 89
4
votes
2 answers

FosRestbundle keeps sending text/html as response and we are expecting json.

Here is our controller: function getLocationsAction(Request $request) { $dm = $this->get('doctrine.odm.mongodb.document_manager'); $query = $dm->createQueryBuilder('MainClassifiedBundle:Location')->select('name', 'state', 'country',…
Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169
4
votes
1 answer

Processing Query Strings?

Built an API using Symfony2, FOSRest and Doctrine. Given the following route: "GET /api/path/to/product" And the following parameters: [("vendorID", 10), ("destination", "tanzania"), ("type", "accommodation"), ("sort", "price", "ASC")] Using…
4
votes
1 answer

FOSRestBundle output wrong xml

My XML output looks wierd when I request for xml.. Controller: use FOS\RestBundle\Controller\Annotations as REST; class RestController { /** * @REST\View */ public function getAgenciesAction() { return…
Almog Baku
  • 810
  • 1
  • 9
  • 22
4
votes
2 answers

FOSRestBundle and JMS Serializer, error when geting JSON

I have been trying out Symfony 2.2, the FOSRest Bundle (using JMS Serializer), and Doctrine ODM using MongoDB. After many hours of trying to figure out how to correctly setup the FOSRest Bundle I'm still having some trouble: I have a very simple…
Onema
  • 7,331
  • 12
  • 66
  • 102
4
votes
0 answers

FOSRestBundle: rendering XML on browser

Let's say I have one REST API call: /api/message/list I want to have different response format depending on HTTP Accept Header. It works perfect when I request for JSON or XML from curl command. But when I load it from browser, it tries to render…
Firula
  • 1,251
  • 10
  • 29
4
votes
1 answer

How to generate custom routes for some actions with FOSRESTBundle?

I actually use automatic route generation for my api Rest, using the FOSRESTBundle, also I use NelmioApiDocBundle to generate the api doc. To generate routes for the api this I have in my routing.yml users: type: rest resource:…
Fernando P. G.
  • 191
  • 2
  • 15
4
votes
0 answers

FosRestBundle. How to return full response on redirect

When I post data to server redirect happens: $view = $this->routeRedirectView('get_config', array('id' => $config->getId())); return $this->handleView($view); Here is a code of action where request is being redirected to: /** * @View() */ public…
Molecular Man
  • 22,277
  • 3
  • 72
  • 89
4
votes
1 answer

LogicException: Container extension "jms_serializer" is not registered

i am trying to add FosComment bundle , FOS Rest Bundle, JMS serializer i get error LogicException: Container extension "jms_serializer" is not registered when they are installed. \can anyone suggest to resolve this problem
Jethik
  • 1,860
  • 1
  • 22
  • 26