Updating resources

Choosing URI formats is an important part of designing RESTful APIs. As seen earlier, rooms are accessed using the path, /rooms/{roomId}, and created under /rooms. And you might recall that as per the HTTP specification, PUT requests can result in creating entities if they do not exist. The decision to create new resources on update requests is up to the service designer. It does, however, affect the choice of path to use for such requests.

Semantically, PUT requests update entities stored under the supplied request URI. This means that update requests should use the same URI as GET requests: /rooms/{roomId}. However, this approach hinders the ability to support resource creation on update, since no room identifier is available. ...

Get Building a RESTful Web Service with Spring now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.