I am using Jersey client to do requests. Here is an example.
https://myschool.com/webapi/rest/student/submitJob?student={student:[{"id":1,"name":"Tom","age":20},{"id":2,"name":"Bob","age":20}]}&score={score:[{"id":1,"math":90,"art":80,"science":70},{"id":2,"math":70,"art":60,"science":80}]}
And the response would be like this: {"jobId":"123456789","jobStatus":"JobSubmitted"}
This is my current code:
String student = {student:[{"id":1,"name":"Tom","age":20},{"id":2,"name":"Bob","age":20}]};
String score = {score:[{"id":1,"math":90,"art":80,"science":70},{"id":2,"math":70,"art":60,"science":80}]}
String responseResult = client.target("https://myschool.com/webapi/rest/student/").path("submitJob")
.queryParam("student", student).queryParam("score", score).request("application/json").get(String.class);
The problem is the real request URI is too long that I got 414 error. So I need to use POST instead of GET method. But I send the request using queryParam but not Body. Could anyone tell me how to do that? Thanks.