O'Reilly logo

Mastering Internet of Things by Peter Waher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Choosing representation

Instead of only providing a fixed format of the content we return from our resource, HTTP allows us to use the Accept header in the request to figure out what format the client desires. This makes it possible to use the resource seamlessly in different types of applications and for different use cases. Returning XML, JSON, or an image, based on client preference, allows us to use the resource in automation and mobile phone apps, or embed it in image tags. If the client wants something we cannot provide, we return a 406 Not Acceptable error back to the client. We do this by throwing an HTTP exception object. If no Accept header is available, we chose to return XML. Note that we also must specify an HTTP header in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required