0

I have been working on a Java project where I have to create a server (Tomcat) and generate an API using Jersey and Java. Currently I am able to get a single user detail using the following code.

@POST
@Path("Singleuser")
@Consumes({MediaType.APPLICATION_JSON , MediaType.APPLICATION_XML})
public Singleuserdetails CreateIteration(Singleuserdetails IT1) {
    repo.create(IT1);
    return IT1;
}

If I run the below API, I am able to get single user.

http://localhost:8080/PersonFinder/webapi/Singleuserdetails/Singleuser/DS-011

I need one more API to retrieve multiple users based on multiple ids. Similar to below example

http://localhost:8080/PersonFinder/webapi/MulitpleUser/id=DS-011?id=SS-067

How can I alter the above method such that I will be able to retrieve multiple ids?

Note: My users are more than 100 in such case. Should I pass all of them as a parameter? is there any other way to make the API work based on N number of inputs from the user? Thanks in advance.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
Divakar R
  • 81
  • 5
  • 12

1 Answers1

0

Create a new function that returns a List<Singleuserdetails>, and use this function to return multiple values in single go.

Talking about high record count, you can consider implementing pagination by passing startIndex and pageSize parameters in URL. Or make use of PagingAndSortingRepository, it contains built in implementation for pagination.

Dark Knight
  • 8,218
  • 4
  • 39
  • 58