0

我正在使用 dart:http 发出发布请求,但似乎我无法指定目标 api 所需的 HTTP1.1 版本。理想情况下,我需要在 dart 中重新创建以下请求:

curl -X POST --http1.1 "https://api.dummyapi.com/v1/route" -H "accept: text/plain" -H "Authorization: 000000-000000-000000-000000" -H "Content-Type: application/json-patch+json" -d "{}"

我目前的版本是这样的:

    final url = Uri.parse('https://api.dummyapi.com/v1/route');

    final response = await http.post(url, headers: {
      'Authorization': '000000-000000-000000-000000',
      'accept': 'text/plain',
      'Content-Type': 'application/json'
    });```
4

1 回答 1

1
Checked the following code example



  Future createUserExample(Map<String,dynamic> data) async {
final http.Response response = await http.post(
    'https://api.dummyapi.com/v1/route',
    headers: <String, String>{
      'Authorization': '000000-000000-000000-000000',
      'accept': 'text/plain',
      'Content-Type': 'application/json'
    },
    body: data,
);
return response;
于 2021-03-25T14:47:20.373 回答