Api 我的FlatterHTTP post请求没有发送表单数据

Api 我的FlatterHTTP post请求没有发送表单数据,api,http,flutter,dart,Api,Http,Flutter,Dart,下面是我的Http post请求,它没有在正文中发送我的表单数据,并且在postman中工作正常。 它只需要电子邮件参数在身体,我现在通过静态,但仍然,我认为我的身体发送空,任何建议请 Future<Map> getJson() async { String apiUrl = 'this is my url'; Map<String, String> headers = { 'Content-Type': 'application/js

下面是我的Http post请求,它没有在正文中发送我的表单数据,并且在postman中工作正常。 它只需要电子邮件参数在身体,我现在通过静态,但仍然,我认为我的身体发送空,任何建议请

   Future<Map> getJson() async {
    String apiUrl = 'this is my url';

    Map<String, String> headers = {
      'Content-Type': 'application/json',
      'Authorization':'this is my security token'

    };
    final msg = jsonEncode({
      "email":"shahid31347@gmail.com",
    });

    http.Response response = await http.post(
      apiUrl,
      headers: headers,
      body: msg,
    );
    return json.decode(response.body); // returns a List type
  }

  void check() async{
Map _data = await getJson();
 print("$_data");
  }


  @override
  void initState() {
    super.initState();
    check();
  }
我的代码响应

{status: ERROR, data: {msg: fields are required}}

如果您发布表单数据,请使用此代码

var uri = Uri.parse('https://example.com/create');

var request = http.MultipartRequest('POST', uri)
  ..fields['email'] = 'example_email@gmail.com';

  request.headers.addAll({
      'Content-Type': 'multipart/form-data',
      'Authorization':'your token'
    });


var response = await request.send();
if (response.statusCode == 200) print('Done!');
var uri = Uri.parse('https://example.com/create');

var request = http.MultipartRequest('POST', uri)
  ..fields['email'] = 'example_email@gmail.com';

  request.headers.addAll({
      'Content-Type': 'multipart/form-data',
      'Authorization':'your token'
    });


var response = await request.send();
if (response.statusCode == 200) print('Done!');