简体   繁体   English

在REST API中放置和删除

[英]PUT and DELETE in REST API

I have a question that still i have been using PUT and Delete in Web service (REST API) methods for respectively Update a resource and Delete a resource but i am informed now by mobile developers that its not good and always use POST method of HTTP to update and delete. 我有一个问题,我仍然一直在分别使用PUT和Web服务中的删除(REST API)方法来更新资源和删除资源,但是移动开发人员现在通知我它不好,并且始终使用HTTP的POST方法来更新和删除。 Can i know how far is it true according to current world of technology ? 我能知道目前的技术水平到底有多远吗?

This is how i used. 这就是我使用的方式。

Create -> Post
Read   -> Get
Update -> Put
Delete -> Delete

Suggest me the best API documentation that is available online with best practices. 向我建议最好的API文档,可在线获取最佳实践。

I think the problem is mostly related to some browsers or JavaScript frameworks not properly passing DELETE and PUT on Ajax calls. 我认为问题主要与某些浏览器或JavaScript框架未在Ajax调用中正确传递DELETEPUT有关。

There's an overview of the --more or less-- current state for DELETE here: 这里概述了DELETE或多或少)当前状态:

Are the PUT, DELETE, HEAD, etc methods available in most web browsers? 大多数Web浏览器中都可以使用PUT,DELETE,HEAD等方法吗?

and here (marked duplicate, but some different answers): 在这里(标记为重复,但有一些不同的答案):

Which browsers don't support a HTTP DELETE with jQuery.ajax? 哪些浏览器不支持jQuery.ajax的HTTP DELETE?

No mention of mobile browsers in particular, though. 但是,没有特别提到移动浏览器。

A lot of frameworks use a hidden input in a post request to tell the server what rest method it "really" is. 许多框架在发布请求中使用隐藏的输入来告诉服务器它“真正”是什么休息方法。 Like this: 像这样:

<input type="hidden" name="_METHOD" value="PUT"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM