0

I have a REST service for Company/Department. Company which contains departments.

I have written CRUD service for company and department but when I retrieve a company with an id, I want Company object should make a nested REST API call and show all the departments of that company in hierarchical way.

Something like this:

<company>
    <companyId> 1001 </companyId>
    <companyName>company name</companyName>
    <departments>
        <depaId>1111</depId>
        <depName>dep name1</depName>
        <depaId>2222</depId>
        <depName>dep name2</depName>
    </departments> 
</company>

Please let me know if someone have some idea about REST nested calls.

Sunil
  • 170
  • 1
  • 3
  • 11

1 Answers1

0

Are departments shared between companies? by that, I mean is one company's marketing department basically the same thing as another company's, or are they seperate concepts? If the former, what you have are simply two resource collections. You should treat them as such, and link from the company to the departments.

<company>
    <link rel="department" href="/departments/5" />
    ...
</company>
Nicholas Shanks
  • 10,623
  • 4
  • 56
  • 80