Debugging Symfony2 cURL responses FOSRestBundle

788 views Asked by At

Currently I am developing an API using the FOSRestBundle in Symfony2. Using cURL I post a JSON object to a controller's action using command line, which in return parses a file and uploads it to S3.

So far so good, but I wish debugging the cURL response was a bit easier. When an error 500 is thrown in Symfony, my cURL response contains a huge amount of HTML. Is there a way to catch the exception message in a human readable format for the command line?

2

There are 2 answers

1
COil On BEST ANSWER

As suggested if your query ask for JSON your error 500 should also returns JSON.

The Postman extension is good, but the easiest way to test your FOSRestBundle API is the use a Symfony2 bundle like NelmioApiDocBundle. You will be able to test all your API actions with a sandbox and to document your whole API.

0
Abdoul Ndiaye On

In the fos rest bundle, you can activate a listener to change the default format of your responses:

fos_rest:
    format_listener:
        rules:
            default:
                fallback_format: json

I also suggest you to use Postman to test your API: Postman