In the recipe Consuming a JSON service, we learnt how lightweight and convenient the JSON format can be for exchanging data. What happens if we not only want to expose data using JSON, but also allow the possibility to modify it? This is one of the reasons why the REST architecture exists. REST stands for Representational State Transfer, and is no more than a set of principles that guide the concepts that describe its proper implementation.
One of these main principles is that the client-server communication that is part of a REST request should be stateless. This means that no context exists in the server between requests from a specific client. All the information required to perform an operation is part of the request.
In this recipe, we will learn how to add REST services to an application, using JSON as their exchange format. These services will allow any foreign application to get data from a post, create new posts, or delete existing posts.