如何向我的删除http请求中添加正文

时间:2019-02-06 15:19:26

标签: dart flutter

我想在我的删除http请求中添加一个正文,但是http pakage似乎不接受它

http.delete('${config.basicUrl}removeFavorite', body: json.encode(requestBody))

对此有什么解决方案吗?

1 个答案:

答案 0 :(得分:2)

  final client = http.Client();
  try {
    final response = await client.send(
        http.Request("DELETE", Uri.parse("${config.basicUrl}removeFavorite"))
          ..headers["authorization"] = "Bearer $bearer"
          ..body = "...");
    //
  } finally {
    client.close();
  }