Git Product home page Git Product logo

Comments (7)

orliesaurus avatar orliesaurus commented on July 28, 2024 1

@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.

orliesaurus avatar orliesaurus commented on July 28, 2024

Hi @varunkm what API are you trying to consume?

from unirest-java.

varunkm avatar varunkm commented on July 28, 2024

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.

varunkm avatar varunkm commented on July 28, 2024

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.

varunkm avatar varunkm commented on July 28, 2024

@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.

orliesaurus avatar orliesaurus commented on July 28, 2024

Glad I could help

from unirest-java.

sargue avatar sargue commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.