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 594109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:55:05+00:00 2026-05-13T15:55:05+00:00

I am currently adding a REST API over http to an online service and

  • 0

I am currently adding a REST API over http to an online service and I am confronted with a very simple problem for which I cannot find an answer that satisfies me:

I have mainly 2 resources: ‘user’ and ‘reports’, as you would have guessed reports are associated to users (to one and only one, = foreign key in my db)

Anyway I have this url mapping for GET :

  • mywebsite/api/users/{id} : returns a user and related information, or a list of users if id is not present
  • mywebsite/api/report/{id} : returns a report and related information, or a list of reports if id is not present

Now I would like to get the reports for a specific user, my way of doing it now is to add an optional parameter to the GET method for reports: ?username={username} and if it is present, I am filtering the results to return only the reports for this user.

I can’t help but think something is wrong… if I start doing things like this I will have my methods handling GET full of if/else looking for missing parameters…

Other solutions I I thought of are:

  • incorporate the reports in the resulting GET on mywebsite/api/users/{id} but I have many many reports so in the end it will become really bad…
  • map another url just for this function, but it just doesn’t feel right…

I am just getting the grips of this REST thing, I like the concept but a little explanation on this matter would really help me understand it better.

Thanks

Edit:

It seems I have hit a common problem in the REST world, I have tied my resources to a model. If you tie a resource to a model you end up having trouble with aggregate attributes.
Some guy describes this error here http://jacobian.org/writing/rest-worst-practices/ but I have yet to understand how to manage that as he said…

fyi I am using django/piston but this question should be answerable regardless of any language.

  • 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-05-13T15:55:06+00:00Added an answer on May 13, 2026 at 3:55 pm

    I can’t help but think something is wrong…

    The only thing you’re doing wrong is thinking that your URI structure makes your application more or less RESTful. The original REST literature never says that query strings are bad. People tend to get hung up on URI structure and seem to think that your URIs must be structured a certain way to be considered RESTful. There is nothing wrong with using ?username=<username>. A URI is just an ID (though some can be more human friendly than others).

    Bottom line: don’t get hung up on how your URIs look. There are much more important things to focus on (promoting hyperlinking/hypermedia, sticking to a uniform interface – typically HTTP, cacheability, etc.).

    This may be a big of a digression but, as for your comment about the coupling of resources to models, you’re still okay. If you do go the /reports/ID/user route, just think of ‘user’ as a relationship name on your reports model. Surely your model defines the relationship between a report and a user. You can just parse the last part of your URI so that it matches the name of this relationship. In the case of one to one relationship like you describe its always a good idea to also set the Content-Location header to match the canonical URI of the user.

    For example. Say report 123 belongs to user 1. You now have two ways of referring this user:

    http://example.com/reports/123/user
    http://example.com/user/1
    

    For the first URI, it would also be a good idea to set Content-Location: http://example.com/user/1 header

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

Sidebar

Related Questions

I have a simple WCF4 REST service which is working fine when using a
Currently I have a loop that tries to find an unused filename by adding
I'm trying to implement a REST API to my website. My problem is that
I'm currently implementing a WCF REST service on a web role in Windows Azure,
I'm calling the Firebase REST API from a Node.js process. The problem I'm seeing
I'm currently adding a div to use as a slider programmatically, but when I
I am currently adding products programatically to the cart, to create a 'free sample'
I'm currently adding transposition tables in my chess engine, and I'm having issues with
I currently am adding some features to our logging-library. One of these is the
I'm adding a toolbar to my application and currently I'm adding some toggle buttons

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.