【发布时间】:2014-01-22 23:04:39
【问题描述】:
我正在设计 REST API。在家中创建房间的 POST 请求之一需要输入家庭 ID 和房间名称,例如:
POST /webCall/development/construction
<?xml version="1.0"?><room><home id='110001'/><name>large bedroom</name></room>
所以我的问题是,假设家庭ID = 110001,在系统中不存在,那么应该404(未找到资源)作为响应码或412(前提条件失败)作为响应码。
可能的争论。
Why 404 : The resource home with ID : 110001 is not found.
Why 412 : The precondition to create a room is that a home should exist,which fails here.
请提供您的建议并说明理由,这将有助于我做出正确的决定。
【问题讨论】:
标签: java web-services http rest http-response-codes