I am building a flutter app, everything is alright if I use http requests but when it come to https, I am unable to get or post https request, debugger gives no error, even it does not print response of the request. I tried, flutter clean
and rebuild app so many times even clearing my mobile device cache etc. it does not work
I am working and testing on android device
Code
import 'dart:convert';
import 'package:http/http.dart' as http;
var url = Uri.parse('https://my.api-end-point.com:port/auth');
Map requestHeaders = <String, String>{
'Content-type': 'application/json',
'Accept': 'application/json'
};
Map body = <String, String>{'email': email, "password": password};
var response = await http.post(url, headers: requestHeaders, body: json.encode(body));
var res = jsonDecode(response.body);
print(res);
** Test ** working also on postman
CodePudding user response:
Have you tried hitting the same api using postman? may be there is an issue with the api itself since the console returns no errors
CodePudding user response:
Please check below link. It has complete guide of how to call an API. Though if you are facing difficulty, please share the error you are getting so I can check exact issue.