Skip to content

Instantly share code, notes, and snippets.

@gregory
Forked from hjr3/truck.md
Created February 17, 2014 18:49
Show Gist options
  • Save gregory/9056579 to your computer and use it in GitHub Desktop.
Save gregory/9056579 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/hal+json


HTTP/1.1 200 OK
Date: Mon, 20 Jun 2011 21:15:00 GMT
Content-Type: application/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/hal+json


HTTP/1.1 200 OK
Date: Mon, 20 Jun 2011 21:15:00 GMT
Content-Type: application/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