Nitika
Nitika

Reputation: 205

How to pass two parameters in a post request?

I have a post request being sent in the following manner:

final private ObjectMapper mapper;
...
...
Response response =target.request().post(Entity.entity(mapper.writeValueAsString(feedbackFilterDataForDA),
                    APPLICATION_JSON));

And the request goes to a function of type:

public Response getData(FeedbackFilterDataForDA f,ArrayList<String> a) {
}

How should I change the post request to take both the parameters as input?

Upvotes: 0

Views: 145

Answers (1)

Andreas
Andreas

Reputation: 159086

I see three options:

  • Enhance the JSON to include the additional information, e.g. by wrapping the current JSON in another JSON Object with 2 properties.

  • POST the data as application/x-www-form-urlencoded instead of application/json, with one of the values being the JSON payload.

  • POST the data as multipart/form-data instead of application/json, with one part being the JSON payload.

Upvotes: 1

Related Questions