foss42 / apidash

API Dash is a beautiful open-source cross-platform API Client built using Flutter which can help you easily create & customize your API requests, visually inspect responses and generate API integration code. It is supported for macOS, Windows, Linux, Android & iOS. A lightweight alternative to postman/insomnia.
https://apidash.dev
Apache License 2.0
1.61k stars 305 forks source link

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

Open royshruti opened 7 months ago

royshruti commented 7 months ago

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):

animator commented 7 months ago

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

royshruti commented 7 months ago

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 commented 7 months ago

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

aryanraj commented 7 months ago

@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'),
  ],
);