我正在设计 REST API。在家里创建房间的 POST 请求之一需要输入家庭 ID 和房间名称,例如:
POST /webCall/development/construction
<?xml version="1.0"?><room><home id='110001'/><name>large bedroom</name></room>
所以我的问题是,假设家庭 ID = 110001,在系统中不存在,在这种情况下应该 404(Resource not found) 是响应代码或 412(Precondition failed) 是响应代码。
可能的争论。
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.
请提供您的建议与推理,这将有助于我做出正确的决定。