Skip to content

Instantly share code, notes, and snippets.

@frankmayer
Forked from hjr3/truck.md
Last active December 10, 2015 09:59
Show Gist options
  • Save frankmayer/4417864 to your computer and use it in GitHub Desktop.
Save frankmayer/4417864 to your computer and use it in GitHub Desktop.

Examples of HAL+json API calls for a truck

Get Trucks

GET /trucks HTTP/1.1
Host: api.example.com
Authorization: Basic username:password
Accept: application/vnd.hal+json


HTTP/1.1 200 OK
Date: Mon, 20 Jun 2011 21:15:00 GMT
Content-Type: application/vnd.hal+json
Etag: 372b753d68c06990ea22b04b9c9fd4f8

{
   "_links":{
      "self":{
         "href":"/trucks"
      },
      "http://example.com/rels/truck":[{
         "href":"/trucks/1",
      },
      {
         "href":"/trucks/2",
      },
      {
         "href":"/trucks/3",
      }]
   }
}

Get Single Truck

GET /trucks/1 HTTP/1.1
Host: api.example.com
Authorization: Basic username:password
Accept: application/vnd.hal+json


HTTP/1.1 200 OK
Date: Mon, 20 Jun 2011 21:15:00 GMT
Content-Type: application/vnd.hal+json
Etag: 232b753d68c0450ea22b04b9c9fc4f8

{
   "_links":{
      "self":{
         "href":"/trucks/1"
      }
   },
   "year": 1967,
   "make":"Ford",
   "model":"Mustang"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment