Android CRUD Volley + Symfony API Platform - jak debugovat chyby?

Autor Thillde
Publikováno 15.04.2021
Kategorie android
Stav Vyřešeno
Ahoj,

vyvíjím pro android v android studiu a dělám CRUD aplikaci s využitím Volley na HTTP requesty. Data posílám na PHP Symfony s API Platform. V android studiu je v debug často vidět chyba http 400 a http 500. Nedaří se mi čistě v CRUD aplikaci vypisovat jednoduše response odpovědi jako v php a nevím jak to správně debugovat. Autorizace přes header s 'X-AUTH-TOKEN' probíhá na 100% v pořádku. Poradíte prosím někdo co s tím? Díky



Odpovědi na dotaz 1

The English language is translated by machine - the translator can modify eg cited codes = it is better to use codes from the Czech original.

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

RE: Android CRUD Volley + Symfony API Platform - jak…

Autor Oxytocin
Publikováno 21.05.2021
Kategorie android
Stav Zkontrolováno
Ahoj,

já debug takových API requestů řeším přes log v Symfony - v linuxu dám příkaz tail /var/www/app7/var/log/dev.log

Log ti pak zobrazí konkrétní chyby z API platform:


[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@superuser.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"} []


1

The English language is translated by machine - the translator can modify eg cited codes = it is better to use codes from the Czech original.

Android CRUD Volley + Symfony API Platform - how debug errors?

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@superuser.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"} []
Tento web používá k poskytování služeb, personalizaci reklam a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tím souhlasíte. Další informace