0
static Future<RequestArray> requestQuotesListHistory(
      String url, Map bodyx) async {
    Map<String, String> _header = <String, String>{
      "Authorization": "Bearer $vToken",
    };
    try {
      print(_header);
      print(vToken);
      final response = await http.post(
        Uri.parse(url),
        headers: _header,
        
        body: bodyx,
      );
      if (200 == response.statusCode) {
        print(response.headers);
        var jsonString = response.body;
        print(jsonString);
        var jsonMap = json.decode(jsonString);
        print(jsonMap);
        var rqQuoteList = RequestArray();
        rqQuoteList = RequestArray.fromJson(jsonMap);
        return rqQuoteList;
      } else {
        return RequestArray();
      }
    } catch (e) {
      return RequestArray();
    }
  }

The issue is that I sent the authorization in a case-sensitive format, but when I made the API call, the response I received was the array shown below:

I/flutter (15684):
[user-agent] => Dart/2.19 (dart:io)
[content-type] => application/x-www-form-urlencoded; charset=utf-8
[accept-encoding] => gzip
[content-length] => 57
[authorization] => Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
[host] => api.ss.com
Andreas Violaris
  • 2,465
  • 5
  • 13
  • 26
Mukesh kumar
  • 101
  • 1
  • 4
  • issues have send the Map _header = { "Authorization": "Bearer $vToken", }; have sent the Authorization key in the header, but the server returns the [authorization] key in dart language is what do – Mukesh kumar Mar 24 '23 at 11:45
  • the server supports Authorization word (not - authorization). do you dart sdk support -Authorization vs authorization? – Mukesh kumar Mar 24 '23 at 11:52
  • This means your server is not RFC complaint, which states that header keys are case insensitive. Dart lower cases all header keys, hoping that most/all servers *are* RFC compliant. To get around this you need to go lower that the `http` library and use the dart io `HttpClient` class. Its request object gives you more direct access to the headers and the `add` method allows to preserve the case of the header key. See: https://api.dart.dev/stable/2.19.5/dart-io/HttpHeaders/add.html – Richard Heap Mar 24 '23 at 12:27
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – bqubique Mar 24 '23 at 22:42

0 Answers0