首页 > 解决方案 > 如何在我的删除 http 请求中添加正文

问题描述

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

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

有什么解决办法吗?

标签: dartflutter

解决方案


  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();
  }

推荐阅读