How do I debug a REST request when I can’t see the output of "dump()" calls?

I want to debug the Request sent to my Controller method :

use FOSRestBundleControllerAnnotations as Rest;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;

class IteropController extends AbstractController
{

    /**
     * @RestPost("/api/getiterop", name="api_get_iterop")
     * @RestRequestParam(name="sary", nullable=true)
     */
    public function getIteropForm(Request $req)
    {
        $response = new Response();
        $response->headers->set('Access-Control-Allow-Origin', '*');
        $response->headers->set('Content-Type', 'application/json');
        $response->setContent(json_encode(['prenom' => $req->request->get('prenom') , 'sary' => $req->files->get('sary') ? 'misy' : 'tsisy']));
        dump($req->getContent());
        return $response;
    }
}

But at runtime I get (failed)net::ERR_FAILED in the Network tab of the browser development tool, and the CORS error appears on the console log of the browser.

So how to debug the Rest POST?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *