Writing a query parameter with an array of values in Flutter

Viewed 25

I'm using the Http package on flutter. I have a query request that should take a large list of values localhost/accounts/fax-info?ids=(66, 97) this works in post man however. In flutter I tried this exact thing and it just gives me a general error that doesn't tell me anything.

Future<List<CustomerInfo>> getFaxinfo(
    List<UnfinishedAccount> accounts,
  ) async {
    final baseUrl = 'localhost';
    final int port = 3003;
    final accountsPath = '/accounts';
    final accountsFaxInfoPath = '$accountsPath/fax-info';

    try {
      final uri = Uri.parse('http://localhost:3003/accounts/fax-info?ids=(66, 97)');
      final response = await http.get(uri, headers: headers);
      if (response.statusCode == 200) {
        print(jsonDecode(response.body));
      }
      return [CustomerInfo(sent: 200, received: 300, name: 'Test')];
    } catch (err) {
      print(err);
      rethrow;
    }

I tried mapping the values of accounts.id then converting that to a list, I'm not sure if that's the correct way to put it in the query as a list of values because it looks like (66,97) not [66, 97].

0 Answers
Related