Posts

Showing posts with the label rest

REST API Best practice ? return Empty object vs no object

5 The bounty expires in 16 hours . Answers to this question are eligible for a +50 reputation bounty. maaz is looking for an answer from a reputable source . let's say i have an API that returns users wallet balance and List of wallet transactions which is going to expiry response = { user_balance: 20 expiring_credits : [ {object 1 } {object 2} ] } in case if user dont have any expiring transactions we can format respose in 2 ways option 1 response = { user_balance: ...

Json Flutter - Error with Json post method in Flutter giving HTML error

i am trying to post to an api by flutter but it give me this error : I/flutter ( 5558): <!DOCTYPE html> I/flutter ( 5558): <html lang="en"> I/flutter ( 5558): <head> I/flutter ( 5558): <meta charset="utf-8"> I/flutter ( 5558): <title>Error</title> I/flutter ( 5558): </head> I/flutter ( 5558): <body> I/flutter ( 5558): <pre>Cannot POST /login</pre> I/flutter ( 5558): </body> I/flutter ( 5558): </html> I/flutter ( 5558): POST http://192.168.1.5:5000/login my code : void create() async { Dio dio = Dio(); var response = await http.post('http://192.168.1.5:5000/login',headers: { "Accept":"application/json", },body: { "username": "${usernameController.text}", "password": "${passwordController.text}" }); print(response.body); print(response.request); } anyone can help plz...