MartinM
MartinM

Reputation: 1574

How to specify Flutter/dart HTTP protocol version (HTTP/1.1, --http1.1)

I am using dart:http to make post request but it seems I cannot specify HTTP1.1 version which is required by target api. Ideally I need to re-create following request in 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 "{}"

My current version is this:

    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'
    });```

Upvotes: 0

Views: 1284

Answers (1)

Mohamed Mesalm
Mohamed Mesalm

Reputation: 732

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;

Upvotes: 0

Related Questions