O'Reilly logo

Building a RESTful Web Service with Spring by Ludovic Dewailly

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

The API response format

It is up to API designers to decide which format best suits their use case. That being said, it is good practice to settle on a common response envelope format. With this approach, a RESTful web service provides a uniform interface, enabling the client developers to handle responses in a consistent manner, regardless of the operation being invoked.

The next section offers a sample envelope format.

The envelope format

The first piece of information that is relevant to any operation is whether it was successful. We can encapsulate that information with a status. Secondly, most requests will return data. Therefore, a field in our envelope could provide generic access to the response payload. The following format will form 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