I have come across numerous JSON over HTTP APIs that were suppose to be RESTful but I'm not sure if the following design is adhering to REST principals - Request model is used as a subset of Response model.
For example, POST /flight/inquiry Request :
{
"flight_no":"2384B",
"departure_time":78163918839123,
"arrival_time":78163918889382,
...
}
Response :
{
"request" :
{
"flight_no":"2384B",
"departure_time": 78163918839123,
"arrival_time": 78163918889382,
...
}
"status" : "ON TIME"
"last_updated" : 7816391884313,
...
}
If we analyze this in terms of Richardson Maturity Model, I think it will not qualify for level 1 because there is no clear definition of a Resource. If we call 'Inquiry' as the resource here, the response should not have result on the inquiry such as status, last_updated, etc. Typically, it should respond with an inquiry_id (like 123) that can be passed to a second end point GET /flight/123/status
.
This approach, though is more aligned with REST principles (correct me if I'm wrong), developers tend to avoid it simply because it's easy to squeeze the same behavior in a single end point rather than two. My question is, are there consequences to ignoring REST principles in situations like these where it is simpler to take shortcuts?