Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9130621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:59:41+00:00 2026-06-17T07:59:41+00:00

When i have a resource, let’s say customers/3 which returns the customer object and

  • 0

When i have a resource, let’s say customers/3 which returns the customer object and i want to return this object with different fields, or some other changes (for example let’s say i need to have include in customer object also his latest purchase (for the sake of speed i dont want to do 2 different queries)).

As i see it my options are:

  • customers/3/with-latest-purchase
  • customers/3?display=with-latest-purchase

In the first option there is distinct URI for the new representation, but is this REALLY needed? Also how do i tell the client that this URI exist?

In the second option there is GET parameter telling the server what kind of representation to return. The URI parameters can be explained through OPTIONS method and it is easier to tell client where to look for the data as all the representations are all in one place.

So my question is which of these is better (more RESTful) and/or is there some better way to do this that i do not know about?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:59:41+00:00Added an answer on June 17, 2026 at 7:59 am

    I think what is best is to define atomic, indivisible service objects, e.g. customer and customer-latest-purchase, nice, clean, simple. Then if the client wants a customer with his latest purchases, they invoke both service calls, instead of jamming it all in one with funky parameters.

    Different representations of an object is OK in Java through interfaces but I think it is a bad idea for REST because it compromises its simplicity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is pure curiosity. Let's say I have a resource Users and want to
Let's say I have a resource file which exports mc1 with 4 frames in
Let's say I have a resource that can have two different behaviors when delete
Let's say I have a method that returns a list of customers and as
Consider that I have 1 resource and 2 urls (let's say new one and
Say I have a resource (e.g. a filehandle or network socket) which has to
Let's say you have a piece of code like: resource = allocateResource(); try {
Let's say I have a Closeable object injected through Guice using request scope: @Provides
I have an image (let's call it original image ) on which I want
I have this problem accessing TextView inside Relative Layout inside LinearLayout Let's say I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.