Skip to content

Can not pass multiple query parameters with same key name #268

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

Open
royshruti opened this issue Mar 9, 2024 · 9 comments · May be fixed by #681
Open

Can not pass multiple query parameters with same key name #268

royshruti opened this issue Mar 9, 2024 · 9 comments · May be fixed by #681
Labels
good first issue Good for newcomers

Comments

@royshruti
Copy link
Contributor

Describe the bug/problem

On passing multiple query parameters with the same key name but different values, only one persists in the final query parameter map. The value of this key is the last pair of key and value added in the Request section.

Bug Preview

Screenshot 2024-03-08 172200
Screenshot 2024-03-08 172255
Screenshot 2024-03-08 172331

Steps to Reproduce the bug/problem

  1. Go to the 'URL Params' tab of the 'Request' section.
  2. Add two or more than two URL Parameters with same key name and different values.

Expected behavior
All the URL Parameters should be passed to the URL.

Device Info (The device where you encountered this issue):

  • OS: Windows
  • Version: Windows 11
@royshruti royshruti added the bug Something isn't working label Mar 9, 2024
@animator animator added the invalid This doesn't seem right label Mar 9, 2024
@animator
Copy link
Member

animator commented Mar 9, 2024

Not a bug. Query parameters keys are supposed to be unique.

@animator animator closed this as completed Mar 9, 2024
@royshruti
Copy link
Contributor Author

royshruti commented Mar 10, 2024

Hello @animator !!!!

With reference to some resources I would like to clarify what I was trying to point out:

  1. MDN docs
    *Here with proper code snippet examples it is shown that how 'getAll()' method returns all the values associated with a given
    search parameter as an array. (JS)

  2. Stackoverflow
    *Correct way to pass multiple values for the same parameter name.

  3. In the following example for same named input, while selecting all the checkbox, console shows 'stocks=google&stocks=meta&stocks=microsoft'
    gith

gith1

Since both the server can read it and browser can produce it, thus to test the server side script, we should have the functionality in API Dash too.

@animator
Copy link
Member

animator commented Mar 10, 2024

@royshruti Thanks for providing the explanation & relevant links.
I am reopening this issue.

@animator animator reopened this Mar 10, 2024
@animator animator added good first issue Good for newcomers and removed invalid This doesn't seem right labels Mar 10, 2024
@aryanraj
Copy link

@animator For this to work we will need to update the expectation for codegen request models which are explicitly set to override here.

/// GET request model with override query params
const requestModelGet3 = RequestModel(
  id: 'get3',
  url: 'https://api.apidash.dev/country/data?code=US',
  method: HTTPVerb.get,
  requestParams: [
    NameValueModel(name: 'code', value: 'IND'),
  ],
);

@animator animator added good first issue Good for newcomers and removed good first issue Good for newcomers labels Mar 12, 2024
@ashitaprasad ashitaprasad removed the bug Something isn't working label Mar 2, 2025
@badnikhil
Copy link
Contributor

badnikhil commented Mar 17, 2025

@animator I have fixed this issue.. are there any tests you want me to perform before opening a PR?..
I will start working on #166 after this. The response had all ids i entered..

Code from view Code -
curl --url 'https://jsonplaceholder.typicode.com/posts?id=2&id=1&id=4&id=10'

Image

@badnikhil
Copy link
Contributor

badnikhil commented Mar 18, 2025

also i am not the one being Loyal to a single language (Multilingual). I can also upgrade codegen for other languages to handle multiple same params.. It would take only a day or two.This will also help me revise many things.
Also in the codegen .. which is more preffered?

query params having only the added params

final response = await dio.Dio().get(
'https://jsonplaceholder.typicode.com/posts?id=7',
queryParameters: queryParams,
);

or queryparams having all the params

final response = await dio.Dio().get(
'https://jsonplaceholder.typicode.com/posts',
queryParameters: queryParams,
);

@ashitaprasad
Copy link
Member

@animator I have fixed this issue.. are there any tests you want me to perform before opening a PR?..
I will start working on #166 after this. The response had all ids i entered..

Code from view Code -
curl --url 'https://jsonplaceholder.typicode.com/posts?id=2&id=1&id=4&id=10'

Image

You have to ensure existing tests are corrected and new tests are added for this feature.
The codegen should work correctly for all the languages for this change.

@ashitaprasad
Copy link
Member

also i am not the one being Loyal to a single language (Multilingual). I can also upgrade codegen for other languages to handle multiple same params.. It would take only a day or two.This will also help me revise many things.
Also in the codegen .. which is more preffered?

query params having only the added params

final response = await dio.Dio().get(
'https://jsonplaceholder.typicode.com/posts?id=7',
queryParameters: queryParams,
);

or queryparams having all the params

final response = await dio.Dio().get(
'https://jsonplaceholder.typicode.com/posts',
queryParameters: queryParams,
);

Query parameters having all params

@badnikhil
Copy link
Contributor

@animator I have fixed this issue.. are there any tests you want me to perform before opening a PR?..
I will start working on #166 after this. The response had all ids i entered..
Code from view Code -
curl --url 'https://jsonplaceholder.typicode.com/posts?id=2&id=1&id=4&id=10'
Image

You have to ensure existing tests are corrected and new tests are added for this feature. The codegen should work correctly for all the languages for this change.

I'll make sure of it

@badnikhil badnikhil linked a pull request Mar 20, 2025 that will close this issue
8 tasks
@animator animator pinned this issue Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
5 participants