Over a million developers have joined DZone.

RESTful and HATEOAS Services: Revisited

Still not clear on the differences between RESTful and HATEOAS services? Read on for some clarity.

· Integration Zone

Is iPaaS solving the right problems? Not knowing the fundamental difference between iPaaS and dPaaS could cost you down the road. Brought to you in partnership with Liaison Technologies.

I get a lot of traffic for my original article on RESTful and HATEOAS services, so I’ve decided to update and revise the article.

REST stands for Representational State Transfer. The main selling point of RESTful Services is that they are designed to be used on the internet using HTTP. It has the following constraints –

  • Resources: Easily understood directory structure URI.
  • Uniform Interface: Create, Retrieve, Update, Delete are accessed over HTTP via POST, GET, PUT, and DELETE methods.
  • Messages: Most commonly these are JSON, but can be any format — HTML, XML, plain text, …
  • Stateless: Interactions not stored, and state is handled in the request.

RESTful Examples

GETSelectGET /customerservice/customers/1
POSTCreatePOST /customerservice/customers
PUTUpdate or Create – IdempotentPUT /customerservice/customers
PATCHUpdate only – IdempotentPATCH /customerservice/customers/1
DELETERemove recordDELETE /customerservice/customers/1

The HTTP return codes are used for success/failure:

4xxClient Error
5xxServer Error

HATEOAS is an additional constraint on RESTful services. It requires the response to return the location of the data, and you can also return a list of other operations at that point. The advantage of this approach is that you can navigate the RESTful service model.

HATEOAS Examples

GET customerservice/customers/1 HTTP/1.1 HTTP/1.1 200 OK

<?xml version=”1.0″?>

Would have an additional link paramater to show its source

<?xml version=”1.0″?>
<link rel=”self” href=”http://localhost:8080/customerservice/customers/1″; />

Discover the unprecedented possibilities and challenges, created by today’s fast paced data climate and why your current integration solution is not enough, brought to you in partnership with Liaison Technologies.

restful services ,services ,representational state transfer ,selling ,hateoas ,restful

Published at DZone with permission of Martin Farrell, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}