Comments (7)
@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)
from unirest-java.
Hi @varunkm what API are you trying to consume?
from unirest-java.
It is one that is still under development. I'd like to be able to post two fields with the same parameter. I think that Unirest replaces the first field with the second one because it has the same parameter.
from unirest-java.
This is how it would be done without Unirest.
httpPost = new HttpPost(url);
httpPost.setHeader("Authorization", "Token " + apiKey);
HttpEntity entity = MultipartEntityBuilder
.create()
.addTextBody("parameter", "value1")
.addTextBody("parameter", "value2")
.build();
httpPost.setEntity(entity);
from unirest-java.
@orliesaurus You are right, it is an issue with the API. It has been fixed to allow an array of values to be posted under one parameter.
Sorry for the inconvenience.
from unirest-java.
Glad I could help
from unirest-java.
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:
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
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.
from unirest-java.
Related Issues (20)
- bug query get with version 4 HOT 5
- Jackson MismatchedInputException for successful response with no body, after migrating to Unirest 4 HOT 2
- Automatic Retries not being used HOT 2
- MockClient: allow fine grained request verification or "un-expected" routes HOT 2
- Request cancellation (such as download cancellation) HOT 2
- Can't turn auto retries standard on HOT 10
- Incorrect Unirest version in README.md HOT 1
- Incorrect link to Interceptor file HOT 1
- Supported windows versions
- Configured HttpClient.Version ignored HOT 10
- MockClient: Mocking same route with different methods only invokes first registered/expected mocking response HOT 2
- multipart/form-data POST is missing content types HOT 6
- How to set read timeout duration HOT 4
- Can we add a response failure retry function? HOT 1
- Making header method to avoid redundant typing. HOT 2
- Make all HttpRequest.asObject work the same way HOT 2
- Strange behavior of response.getRequestSummary().getUrl() HOT 3
- Support the Partitioned flag on cookies HOT 1
- Is Unirest supported Server-Sent Events? HOT 2
- Requests are cancelled unexpectedly - connectTimeout limits request duration HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unirest-java.