Article ID: 121348, created on Apr 28, 2014, last review on May 7, 2014

  • Applies to:
  • APS 2.x

Question

I have a resource that has a one to many relationship with some other resource. How do I fetch all resources linked to my resource?

Answer

You can fetch resources linked to your resource if you query the relationship.

For example, you have a resource 'tenant' that has a one to many relationship with users type, it can look in schema like this:

  "relations": {
    ....
    "users": {
      "type": "http://owncloud.org/users/1.0",
      "collection": true
    }
}

Then, you can query users linked to your tenant using this REST query:

GET /aps/2/resources/[tenant_resource_id]/users

If my tenant resource has ID of caeb15e1-289f-4e48-8c6c-db6c86cc4378, I can run it like this:

GET /aps/2/resources/caeb15e1-289f-4e48-8c6c-db6c86cc4378/users
----
[
{
    "aps":
    {
        "type": "http://owncloud.org/users/1.0",
        "id": "befc7596-e86d-4ae7-ac02-7fc5ee73313c",
        "status": "aps:ready",
        "revision": 3,
        "modified": "2014-04-25T00:23:47Z"
    },
    "homedir": "/var/www/html/owncloudsite/data/user03@example101.local",
    "owncloudusername": "user03@example101.local",
    "quota": null,
    "serviceUserId": "47dd69f9-2e45-421f-af6a-73b91ff3d048",
    "userstatus": "Ready",
    "userusage": 0
},
{
....

70bf700e0cdb9d7211df2595ef7276ab 717db81efe94e616312b74fb03a5d474

Email subscription for changes to this article
Save as PDF