Android CRUD Volley + Symfony API Platform - how debug errors?
Hello,
I develop for Android in the android studio and make a CRUD application using Volley for HTTP requests. I send data to PHP Symfony with API Platform. In the android studio, the error http 400 and http 500 is often seen in the debug. I can't simply list the response responses in the CRUD application simply in php, and I don't know how to debug it properly. Authorization via the header with 'X-AUTH-TOKEN' is 100% OK. Can anyone please advise what to do with it? Thanks
Hello,
I debug such API requests via log in Symfony - I will give the command in Linux
The log will then show you specific errors from the API platforms:
I develop for Android in the android studio and make a CRUD application using Volley for HTTP requests. I send data to PHP Symfony with API Platform. In the android studio, the error http 400 and http 500 is often seen in the debug. I can't simply list the response responses in the CRUD application simply in php, and I don't know how to debug it properly. Authorization via the header with 'X-AUTH-TOKEN' is 100% OK. Can anyone please advise what to do with it? Thanks
REPLY
Hello,
I debug such API requests via log in Symfony - I will give the command in Linux
tail /var/www/app7/var/log/dev.log
The log will then show you specific errors from the API platforms:
[0000-05-21T08:15:41.622469+02:00] request.INFO: Matched route "api_items_post_collection". {"route":"api_items_post_collection","route_parameters":{"_route":"api_items_post_collection","_controller":"api_platform.action.post_collection","_format":null,"_api_resource_class":"App\\Entity\\item","_api_collection_operation_name":"post"},"request_uri":"http://192.168.3.7:8016/api/items?q=%2Fapi%2Fitems","method":"POST"} []
[0000-05-21T08:15:41.623217+02:00] security.DEBUG: Checking for authenticator support. {"firewall_name":"api","authenticators":1} []
[0000-05-21T08:15:41.623254+02:00] security.DEBUG: Checking support on authenticator. {"firewall_name":"api","authenticator":"Symfony\\Component\\Security\\Guard\\Authenticator\\GuardBridgeAuthenticator"} []
[0000-05-21T08:15:41.626076+02:00] doctrine.DEBUG: SELECT t0.id AS id_1, t0.email AS email_2, t0.roles AS roles_3, t0.password AS password_4, t0.name AS name_5, t0.api_token AS api_token_6 FROM user t0 WHERE t0.api_token = ? LIMIT 1 ["xxxxx"] []
[0000-05-21T08:15:41.626710+02:00] security.INFO: Authenticator successful! {"token":{"Symfony\\Component\\Security\\Guard\\Token\\PostAuthenticationGuardToken":"PostAuthenticationGuardToken(user=\"mxd@cloud.up4.cz\", authenticated=true, roles=\"ROLE_USER, ROLE_API_USER\")"},"authenticator":"Symfony\\Component\\Security\\Guard\\Authenticator\\GuardBridgeAuthenticator"} []
[0000-05-21T08:15:41.626854+02:00] security.DEBUG: Authenticator set no success response: request continues. {"authenticator":"Symfony\\Component\\Security\\Guard\\Authenticator\\GuardBridgeAuthenticator"} []
[0000-05-21T08:15:41.628224+02:00] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Serializer\Exception\NotEncodableValueException: "Syntax error" at /var/www/symfony/app7/vendor/symfony/serializer/Encoder/JsonDecode.php line 92 {"exception":"[object] (Symfony\\Component\\Serializer\\Exception\\NotEncodableValueException(code: 0): Syntax error at /var/www/symfony/app7/vendor/symfony/serializer/Encoder/JsonDecode.php:92)"} []
[0000-05-21T08:15:41.630763+02:00] security.DEBUG: Stored the security token in the session. {"key":"_security_api"} []