[英]PUT response code with 204
My PUT and POST are same, so I am using PUT operation. 我的PUT和POST是相同的,因此我正在使用PUT操作。 Here I need to send response body data when PUT successful eg either new data insert into Cassandra or update existing record.
在这里,我需要在PUT成功时发送响应正文数据,例如将新数据插入Cassandra或更新现有记录。
So, what response code should I use in this case.. code 204 I am using for successful PUT with response body, but it automatic convert into 200 code while testing with POSTMAN. 因此,在这种情况下,我应该使用哪种响应代码。代码204我成功使用带有响应主体的PUT,但是在用POSTMAN测试时,它会自动转换为200代码。 so what should I use here.
所以我应该在这里使用。
If the target resource does not have a current representation and the PUT successfully creates one, then the origin server MUST inform the user agent by sending a 201 (Created) response.
如果目标资源没有当前表示,并且PUT成功创建了一个表示,则原始服务器务必通过发送201(已创建)响应来通知用户代理。 If the target resource does have a current representation and that representation is successfully modified in accordance with the state of the enclosed representation, then the origin server MUST send either a 200 (OK) or a 204 (No Content) response to indicate successful completion of the request.
如果目标资源确实具有当前表示形式并且该表示形式已根据封闭表示形式的状态成功进行了修改,则原始服务器务必发送200(确定)或204(无内容)响应,以指示成功完成了请求。
Based on this (and agreeing with Hank), if you have an entity with your response, you should use 201
. 基于此(并同意Hank的意见),如果您的答复中包含实体,则应使用
201
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.