Selma Selma - 4 months ago 15
Java Question

Multiple parameters for REST API

Is this the right way to have multiple parameters for a REST API ?

@GET
@Path("/id/{userId,type,date}")
@Nullable
@Produces(MediaType.APPLICATION_JSON)
List<Exercise> findExercises(
@ApiParam( value = "User ID", required=true) @PathParam("userId") Long userId,
@ApiParam( value = "Type") @PathParam("type") String type,
@ApiParam( value = "Date") @PathParam("date") String date);


If not, how can i accomplish that?

Answer

I guess this is the right way :

@GET
@Path("/id/{userId}/{type}/{date}")
@Nullable
@Produces(MediaType.APPLICATION_JSON)
List<Exercise> findExercises(
        @PathParam("userId") Long userId,
        @PathParam("type") String type,
        @PathParam("date") String date);
Comments