0

I've got problem: when I send post request to my symfony api, and I try to get $request->request, and dump it (using dd() helper), I get empty parameters array, and I have no idea why it happen.

I'm using Postman to test this api, and my example object looks like:

{
   "day": "2018-10-13T08:50:45.802Z",
   "songs": [
       {
           "title":"Song title",
           "songType": 5,
           "number": 237
       }
    ]
}

And result is: result screenshot

Does anyone know how to get expected request?

KeyMaker00
  • 6,194
  • 2
  • 50
  • 49
darek_kce
  • 13
  • 2
  • Possible duplicate of [Posting JSON objects to Symfony 2](https://stackoverflow.com/questions/9522029/posting-json-objects-to-symfony-2) – mblaettermann Oct 13 '18 at 09:26

1 Answers1

1

By default, Symfony's Request class asumes form data set via HTTP headers.

To fetch the json request body, do this: $data = json_decode($request->getContent(), true);

mblaettermann
  • 1,916
  • 2
  • 17
  • 23