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

Construct a query string with duplicate keys #2341

Open
RobertGummesson opened this issue Mar 17, 2024 · 0 comments
Open

Construct a query string with duplicate keys #2341

RobertGummesson opened this issue Mar 17, 2024 · 0 comments

Comments

@RobertGummesson
Copy link

I need to make a call to an API which uses duplicate parameter keys like this:

/api/feed/index?instrumentId=1&instrumentId=2&instrumentId=3

Normally, I'd use requestParameters with URLEncoding.queryString

    case requestParameters(parameters: [String: Any], encoding: ParameterEncoding)

...but because it's using a dictionary, I can't do:

[
    "instrumentId": 1,
    "instrumentId": 2,
    "instrumentId": 3,
]

This will result in:
Dictionary literal of type '[String : Any]' has duplicate entries for string literal key 'instrumentId'

How do I work around this?

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

1 participant