Skip to content

GET from rel

WARNING

This API is frozen and deprecated. Please use the fluent API from 0.9.4 on

Follows a resource's link by way of its rel and sends a GET request.

Signature

The method signature for GET from rel is:

parameterdescription
resourceThe body of a response from a previous request, in HAL format
relThe name of the link relation this GET request will follow.
parameters(optional) name/value pairs which will be used to create a query string.
learn more
template(optional) if the link is templated, name/value pairs to fill the template.
learn more
headers(optional) add to or override the default headers.
learn more
-> returnsthe JSON from the payload of the response to this request

Examples

Simple example:

The example is based on an API which serves the following:

/
/customers
{
  "_links": {
    "self: {
      "href": "/"
    },
    "customers": {
      "href": "/customers"
    },
    "orders": {
      "href": "/orders"
    }
  }
}
{
  "_items": [
    {
      "membershipId": "A375",
      "givenName": "Pat",
      "familyName": "Smith",
      "active": true,
      "_links": {
        "self": {
          "href": "/customers/A375",
        },
        "edit-form": {
          "href": "/customers/A375/edit-form",
        },
        "orders": {
          "href": "/customers/A375/orders",
        },
        "deactivate": {
          "href": "/customers/A375/deactivate",
          "_note": "PUT to deactivate"
        }
      }
    },
    {
      "membershipId": "R933",
      "givenName": "Darcy",
      "familyName": "Jones",
      "active": false,
      "_links": {
        "self": {
          "href": "/customers/R933",
        },
        "edit-form": {
          "href": "/customers/R933/edit-form",
        },
        "orders": {
          "href": "/customers/R933/orders",
        },
        "activate": {
          "href": "/customers/R933/activate",
          "_note": "PUT to activate"
        }
      }
    },
    ...
    ...
    ...
  ],
  "_links": {
    "self": {
      "href": "/customers"
    },
    "item": {
      "href": "/customers/{membershipId}",
      "templated": true
    },
    "create-form": {
      "href": "/customers/create-form",
    }
  }
}
/customers/A375
/customers/A375/orders
{
  "membershipId": "A375",
  "givenName": "Pat",
  "familyName": "Smith",
  "active": true,
  "_links": {
    "self": {
      "href": "/customers/A375",
    },
    "edit-form": {
      "href": "/customers/A375/edit-form",
    },
    "orders": {
      "href": "/customers/A375/orders",
    },
    "deactivate": {
      "href": "/customers/A375/deactivate",
      "_note": "PUT to deactivate this member"
    }
  }
}
{
  "_items": [
    {
      "orderNumber": "FK9384",
      "partNumber": "009343-12",
      "quantity": 3,
      "_customer_ref": "A375",
      "_links": {
        "self": {
          "href": "/orders/65fd80549561b2884948c312",
        },
        "edit-form": {
          "href": "/orders/65fd80549561b2884948c312/edit-form",
        },
        "parent": {
          "href": "/customers/A375",
        },
        "collection": {
          "href": "/customers/A375/orders"
        }
      }
    },
    ...
    ...
    ...
  ],
  "_links": {
    "self": {
      "href": "/customers/A375/orders"
    },
    "item": {
      "href": "/orders/{id}",
      "templated": true
    },
    "create-form": {
      "href": "/customers/A375/create-form",
    }
  }
}

Released under the MIT License.

Released under the MIT License.