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

How to serialize a custom findBy() method?

When I use findBy(), my data is automatically serialized. $users = $this->getDoctrine()->getRepository('AppBundle:User')->findBy($params, $orderBy, $limit, $offset); /** * @VirtualProperty * @SerializedName("catagory") * @Groups({"user"}) …
Spawnrad
  • 445
  • 6
  • 18
2
votes
1 answer

FOSRestBundle + Symfony 3.4 : rest type not reconized

I'm using Symfony 3.4 with FOSUserBundle, I have imported my project from Symfony 3.3, and now, I have an error : Class could not be determined for Controller identified by "api.yaml" in api.yaml (which is being imported from …
graille
  • 1,131
  • 2
  • 14
  • 33
2
votes
1 answer

Response cache for Symfony REST API

I have a REST API using the FOSREST Bundle. The response is serialized by the JMS Bundle. Now I want to cache some of the responses because serialization takes quite some time. I was thinking of storing the response data after serialization and…
Volker Schmitt
  • 101
  • 1
  • 4
2
votes
0 answers

Getting error when sending XML as body instead of JSON

I'm developing a simple Symfony 4 application with the JMSSerializerBundle and the RestBundle, which saves data from POST requests and returns data for GET requests. The requests mostly uses JSON as format, but I need one POST route with accepts and…
mgluesenkamp
  • 529
  • 6
  • 19
2
votes
1 answer

Symfony Form Type constraint of string validates Integer value

I have a simple entity with three fields: an autogenerated ID, a string and an integer. I have set constraints for the latter two, and the constraint corresponding to the integer field works perfectly. If I send an integer which is not in the range,…
MikelAlejoBR
  • 302
  • 5
  • 15
2
votes
0 answers

Symfony 3 + FOSRestBundle return template/view as json

I hope I post this question in good way. I was trying to find an answer in google and symfony docs, but nothing is helpful for me - maybe due to my symfony skills (I don't know this framework - I'm trying to study :) ). My goal is to get article…
2
votes
1 answer

FOSRestBundle listen on prefix only

I have a Symfony application app and running, I want to run the FOSRestBundle on a prefix only /api/* I did some research and found one answer that mentioned using zone zone: - { path: ^/api/* } But I'm getting the following error: Unable to…
Ayoub_B
  • 702
  • 7
  • 19
2
votes
1 answer

API Rest "The CSRF token is invalid. Please try to resubmit the form."

I'm looking to combine FOS Rest Bundle AND FOS User Bundle to my API application to register new users. The problem is: Can't found best practices for user registration on API Rest Unable to register a user using fos user registration type, got 400…
Liogate
  • 145
  • 1
  • 7
2
votes
1 answer

Symfony 3 form collection of entities with FOSRestBundle

We are using the FOSRestBundle. Assume I would like to create a Ticket object via API with the following JSON body: { "title": "I need help", "symptoms": [1, 4, 6] "author": 31 } The author and array of symptoms reference primary keys…
HenningCash
  • 2,030
  • 18
  • 17
2
votes
0 answers

Route in FOSRestBundle not working

Im stay a few days with this problem. I just read the documentation of this Bundle, but im trying all and nothing work. The problem is always: No route found for "GET /produtos". Im only want a make HTTP get,new,post,put,delete work in html.twig…
2
votes
1 answer

Upload files with path inside json (FosRestBundle)

I'm working on a project where I am most write a Rest component to save a user in the database. The component should also save the photo of the user inside a folder on the server. I'm sending the parameter as Json to my Rest Api. I followed hundred…
Herval NGANYA
  • 135
  • 1
  • 13
2
votes
1 answer

Unit test on REST with basic http authentication is always 401 Unauthorized

I'm making a REST api with basic http authentication. The authentication works as expected in a browser and Postman, status 200 Ok and controller behaving fine if the credentials are entered right, 401 Unauthorized otherwise. The problem is that I'm…
TNCreator
  • 123
  • 6
2
votes
1 answer

How to serve index.html file for an Angular SPA from a Symfony application?

I have been working on a single page application project started a few weeks ago. We've focused so far on the front-end part of the project, built with AngularJS, which allowed for the validation of many aspects of the projected final…
AbVog
  • 1,435
  • 22
  • 35
2
votes
1 answer

JMS Serializer not working on custom repository method with FOSRest

I'm having trouble setting up JMS Serializer and FOSRestBundle, to serialize this custom repository method. If I use $schedules = $em->getRepository('RadioBundle:Schedule')->findAll(); it works fine, but when I try my custom method none of the…
OrderAndChaos
  • 3,547
  • 2
  • 30
  • 57
2
votes
1 answer

Using params in ngResource post URL

I'm working with a FosRestBundle API, and I must pass params in an url post resource to perform an operation. The post resource in FosrestBundle is something like this : api/readQuestion/{contain_id}/{user_id}/{type_id}/Questions So to to send data…
kabrice
  • 1,475
  • 6
  • 27
  • 51