Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Person class with a one to many relationship to Employment. A Person in the CRM can have multiple Employments (historic data).

My current REST URI for this class looks like this:

http://domain/persons GET [collection]
http://domain/persons/{id} GET [resource]
http://domain/persons/{id}/employments GET [collection]

To get the CURRENT active employment (so the employment where the endDate is NULL) should I create a URI or should this be done using a QueryParam?

Basically should I do this:

http://domain/persons/{id}/employments/current GET [resource]


http://domain/persons/{id}/employments?current GET [collection with query param filter]

I'm thinking the second one (with the queryparam) because as far as I understand REST a resource should be identified with a non changable URI. Since the current employment position can change it should be done with a QueryParam.

What are your suggestions?

share|improve this question
up vote 3 down vote accepted

The "current" employment can be identified with a "non-changeable" url: it's always at employments/current. It is allowed to point to a different employment object just as the download link for the "current" version of a library can point at different actual files as the library is updated while retaining the same URI. I would use /employments/current. /employments?current isn't correct as the resource has changed (from a collection of employments to a single employment) but the URI path has not.

share|improve this answer

If you code looks something like this or more complicated

 public class UserRestService {

public Response getPersonById(@QueryParam("id") int id) {

   return Response.status(200).entity("getPseronById is called, id : " + id).build();


All this means is that your first assumption is correct

Use domain/persons/{id}/employments/current

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.