I'm using Insomnia Rest to simulate my frontend JSON data being sent to backend. I tested with Postman as well and the issue is the same:
I send JSON data via POST to backend and, when I print what has come in the $_POST variable, it's empty.
I tried print_r(), json_decode/json_encode aproaches, echo, die(), etc. None of them works. There are two ways I can work with those HTTP requests:
1) Send via "FORM URL Encoded" - this one works pretty well. The problem is it only accepts simple data. It's not possible to create objects for example, which in many cases, is very important to work with;
2) Send via JSON, as mentioned, but in PHP I need to use:
$json = file_get_contents("php://input");
Well, in this case, I already have a more-than-1000-lines code using json_encode/json_decode. Based on this case, JavaScript and PHP seems to do all the conversions needed to send and receive JSON data and thus, HTTP simulation softwares don't.
Has anybody faced something and figured out some workaround?