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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:17:21+00:00 2026-05-28T01:17:21+00:00

Supposed I have two top-level resources Foo and Bar . Now the Foo need

  • 0

Supposed I have two top-level resources Foo and Bar. Now the Foo need to be linked to some of the Bar. In a Java class this might look something like this:

public class Foo {

  Set<Bar> bars;
}

public class Bar { … }

I’d like to shape the XML representation of Foo to something like this:

GET /foos/1

<foo>
  …
  <atom:link rel="self" href="/foos/1" />
  <atom:link rel="bars" href="/foos/1/bars" />
</foo>

So I pretty much expose all Bar assigned to a Foo as nested resource. That means Bar resource have an individual lifecycle (aggregation instead of composition). The nested resource might then expose all linked Bar something like this:

GET /foos/1/bars

<bars>
  <atom:link rel="bar" href="/foos/1/bars/1" />
  <atom:link rel="bar" href="/foos/1/bars/2" />
</bars>

Alteratively I could inline the collection in the <foo>element upfront. However I am still stuck with some questions: While this allows me to nicely remove a Bar from a Foo by triggering a DELETE request to e.g. /foos/1/bars/1 but how would one assign a Bar to a Foo then? Assuming the client would access /bars getting:

GET /bars

<bars>
  <bar>
    …
    <atom:link rel="self" href="/bars/4711" />
  </bar>
</bars>

and deciding it wants to assign /bars/1 to /foo/1/bars. I was thinking about a POST request to /foo/1/bars but was unsure about what to actually submit. A link element pointing to the Bar resource such as the following?

POST /foos/1/bars

<atom:link href="/bars/4711" />

This seems quite okay as the clients would still not need to create URLs and we still satisfy REST constraints. However it feels a bit weird to POST links to the server. Is there a better solution to this scenario?

  • 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-28T01:17:22+00:00Added an answer on May 28, 2026 at 1:17 am

    I think about this in terms of the resources understood by the server rather than the XML representations that flow in response to (say) a GET request. I have RESTful services that return either JSON or XML, or potentially other representations.

    So I agree with your POSTing or PUTing to

     /foos/{fooId}/bars
    

    to specify either the complete list of bars or the addition of some bars.

    The format of the posted payload can be whatever is the natural serialised form for the media-type your’re using. In my case it’s often a JSON string and so in my service implementation would deserialise and see an array of resoruce reference URL strings.

    If your

    <atom:link href="/bars/4711" /> 
    

    also deserialise nicely then I don’t see a problem if the serialised form is a little, um, ornamental.

    Summary: do what’s natural for your (de)serialiser.

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

Sidebar

Related Questions

Suppose I have two top-level tasks: task :publicBuild => [:zipSourceCode, :copyPrivateKey] task :internalBuild =>
Suppose I have two classes with the same interface: interface ISomeInterface { int foo{get;
Suppose you have two seperate ASP.NET Web Application projects that both need to use
Suppose you have two linked servers called Local and Remote respectively. Is there a
Suppose I have two tables that are linked (one has a foreign key to
I've recently discovered that MVC is supposed to have two different flavors, model one
Say I have two tables (I am using Django, but this question is mostly
I have two divs, both with 0.6 opacity. I need them to overlap but
so i have the two following iframe codes: <iframe title=YouTube video player class=youtube-player type=text/html
I have a TableLayout inside a ScrollView, because of some special needs, I need

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.