Dio: Starting from version 2.0.14 it is not possible to pass multiple parameters with same name properly anymore

Created on 6 Mar 2019  Â·  4Comments  Â·  Source: flutterchina/dio

Before one could pass Iterable and Dio would pass multiple parameters with the same name and with values from Iterable. Now Dio just makes toString() of iterable and passes it as value, which is not correct.

Most helpful comment

In current version, queryParameters are handled in the same way as jquery, but you can use [method]Uri API to ignore that, for example:

  dio.options.baseUrl="http://domain.com/";
  Response response = await dio.getUri(
    Uri(path: "api",queryParameters:  {
      "selectedId": ["1", "2"],
    })
  );

All 4 comments

Please take an example.

Hi,

    Response response = await _dio.get(
      "http://domain.com/api",
      queryParameters: {
        "selectedId": ["1", "2"],
      },
    );

I am expecting to have call like this:
http://domain.com/api?selectedId=1&selectedId=2

This worked before, but not in current version

In current version, queryParameters are handled in the same way as jquery, but you can use [method]Uri API to ignore that, for example:

  dio.options.baseUrl="http://domain.com/";
  Response response = await dio.getUri(
    Uri(path: "api",queryParameters:  {
      "selectedId": ["1", "2"],
    })
  );

Curious as to why the change was made, as it seems that the accepted way of passing multiple values for a single parameter is selectedId=1&selectedId=2 rather than selectedId[]=1&selectedId[]=2.

Was this page helpful?
0 / 5 - 0 ratings