Multiple fields with the same parameter in a POST.
See original GitHub issueI am interacting with an API that allows for multiple fields of the same name to be included in a post request. The app is still under development and not available publicly.
HttpResponse<JsonNode> jsonResponse = Unirest.post(url)
.header("Authorization", "Token " + apikey)
.field("parameter", "value1")
.field("parameter", "value2")
.asJson();
The problem I am having is that when I have two fields with the same name, unirest only takes the second one and neglects the first one.
Issue Analytics
- State:
- Created 9 years ago
- Comments:7
Top Results From Across the Web
Correct way to pass multiple values for same parameter name ...
Most applications use the first option you have shown: http://server/action?id=a&id=b .
Read more >Search Multiple Fields Same Parameter
You have two different options. You can either use Crafts search so your string would be listingAgent:*searchterm* OR ...
Read more >REST Post multiple parameters with same name
Hi all, I'm trying to send a REST POST request with a multipart/form-data content. In particular, I need to send the same parameter...
Read more >How to Create Multiple Select Parameters in Tableau | phData
This post will differ as it offers a simplistic approach to developing multiple select parameters and more-or-less uses the same base ...
Read more >Request Parameters in Postman - Javatpoint
Enter the same URL in the Postman text field; you will get the multiple parameters in the Params tab. Even you can write...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@varunkm I am not sure it is REST compliant to have multiple fields with the same name but holding different values, basically you need to rethink the API design you have got and use an array to store the values of that particular field. Someone correct me if I am wrong to assume that 💃 thanks! The above basically tells why #42 is not an issue to me (at least)
Sorry to reopen this old bug but I’ve stumbled upon it right now trying to use this library to access the Mailgun API service.
I disagree on this:
REST is strongly based on HTTP and multiple fields with the same value is a common scenario with HTTP. Be it query strings or form data (body of a POST). The latter is the scenario of the OP.
As an example of an API that requires this usage is the same Mailgun service. To send a mail with multiple attachments you need this funcionality as you can’t send them as query parameters.
I’ve tested this with the Jersey 2 client library and it works fine.