
4 Representing operations with HTTP
This chapter covers
- Designing paths for resources
- Mapping typical actions to HTTP methods
- Representing successes and failures with HTTP status codes
- Choosing data locations in HTTP requests and responses
- Representing “do” operations with HTTP
- Using the REST architectural style
After reviewing the API Capabilities Canvas from a REST perspective and identifying resources, actions, inputs, and outputs, we can translate “Send a message” into a POST
/messages
or POST
/message
request. However, challenges can arise in representing the resource (“message”) with a path (/messages
or /message
) and mapping the freely defined action “Send” to standard HTTP methods like POST
. These examples reveal only a few aspects of a request; more considerations are needed for accurately mapping all the identified elements to HTTP requests and responses. Additionally, not all operations fit neatly in typical create, search, read, update, and delete categories; some are simply verbs, such as “like.” These verb-based “do” operations can complicate HTTP representation.