Home > Mobile >  Flutter API Post Method Can not Send Data to SQL server localhost. Show Error "HTTP Error 400.
Flutter API Post Method Can not Send Data to SQL server localhost. Show Error "HTTP Error 400.

Time:10-19

This is My Flutter Code--

void send() async
{
var bb=json.encode(listModel.toJson());
    var response = await http.post(Uri.parse(
      "http://10.0.2.2:1066/api/Storedata/Add"),
      body: bb,
     headers: {"Content-type": "application/json"},);
if (response.statusCode == 201)
  {
    print("Done");
  }
else
  {
    print(response.body);
    print(response.statusCode);
  }
}

In "bb" variable all data show in json format when i debugged. but show this error "HTTP Error 400. The request hostname is invalid". Please Help!!!!

CodePudding user response:

try adding https instead of http

CodePudding user response:

can you please use Dio package?

  • Related