Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send an array of queryParameters? #315

Closed
MilesAdamson opened this issue May 28, 2019 · 13 comments
Closed

How to send an array of queryParameters? #315

MilesAdamson opened this issue May 28, 2019 · 13 comments

Comments

@MilesAdamson
Copy link

New Issue Checklist

  • [x ] I have searched for a similar issue in the project and found none

Issue Info

Info Value
Platform Name flutter
Platform Version 1.5.4-hotfix.2
Dio Version 2.1.0
Repro rate 100%

Issue Description and Steps

How do I send an array of queryParameters?

In postman, I am able to send a GET with an array of parameters. The URL looks like this and it works fine:

/v2/tickets?templateId=5&templateId=7

I have tried a lot of different ways to do the same in flutter with Dio and can't get it to work:

queryParameters['templateId'] = [1, 2];
queryParameters['templateId'] = ['1', '2'];
queryParameters['templateId'] = `[1, 2]`;
@wendux
Copy link
Contributor

wendux commented May 29, 2019

  var uri = Uri(
    ...
    queryParameters: {
      "templateId": ['1', '2']
    },
  );
  dio.getUri(uri);

@MilesAdamson
Copy link
Author

MilesAdamson commented May 29, 2019

  var uri = Uri(
    ...
    queryParameters: {
      "templateId": ['1', '2']
    },
  );
  dio.getUri(uri);

Thank you, works perfectly. The issue was I was using dio.get() instead of dio.getUri()

@ThinkDigitalSoftware
Copy link

Why is this closed if the issue still exists?

@yousifAlneamy
Copy link

This issue should be reopened

1 similar comment
@shinsenter
Copy link

This issue should be reopened

@shubhamhackz
Copy link

We're still facing this issue, please reopen.

@jonatandorozco
Copy link

Please reopen the issue

@kczpl
Copy link

kczpl commented Apr 12, 2022

I am also facing this issue. Can you please reopen this issue?

@shinolex
Copy link

I'm facing this error too, I just want to send a simple int list but can't

@wizetLee
Copy link

queryParameters: {
   "templateId[]": ['1', '2']
}

This format helped me solve this problem

@adar2378
Copy link

It doesn't work with dio.request method. There are multiple keys with different value from list when dio sends requests

For example:

final _queryParameters = <String, dynamic>{
"categoriesIn": [1,2,3]
}

final response = await dio.request<Object>(path, queryParameters: _queryParameters ....);

When it calls the api I notice that it uses path?categoriesIn=1&categoriesIn=2 instead of path?categoriesIn=1,2

@wizetLee
Copy link

wizetLee commented Feb 20, 2023 via email

1 similar comment
@wizetLee
Copy link

wizetLee commented Oct 26, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests