标签:host sdn img rri patch api png this pos
我们在调用RESTFul服务的时候,有的时候。第三方的服务会提供支持PATCH 操作的方法,在这样的情况下。我们假设我们以下的这样的方式,
去调用PATCH操作。肯定会返回40X的错误。
PATCH /tasks/v1/users/@me/lists/MTIxNzM1OTkzNjgxNTQ1OTcwNTc6MDow HTTP/1.1 content-type: application/json; charset=UTF-8 connection: close accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */* authorization: Bearer ya29.LgALd08g5-NIQxwAAAB111tdMC-Q-jXhMoRxYEUS107_bD9p6xdVEq9tht3dpQ accept-encoding: iso-8859-1,*,utf-8 x-http-method-override: PATCH accept-charset: utf-8 User-Agent: Jakarta Commons-HttpClient/3.0.1 Host: www.googleapis.com:443 Content-Length: 45 { "title":"This is a test for patch 5555" }
然后把这个属性的值设置成“PATCH”,然后就能够了。请看以下的測试的请求和结果。
(1)測试请求(2) 測试返回的结果,说明Patch操作的改动成功了。!!
{ "kind": "tasks#taskList", "id": "MTIxNzM1OTkzNjgxNTQ1OTcwNTc6MDow", "etag": "\"esSgSc9hKkvJ92xs_2jT5Am6L4c/KKY36xrOZKKq3hKD4zW4yCwNmJo\"", "title": "This is a test for patch 5555", "updated": "2014-06-13T08:31:24.000Z", "selfLink": "https://www.googleapis.com/tasks/v1/users/@me/lists/MTIxNzM1OTkzNjgxNTQ1OTcwNTc6MDow" }
RESTFul中的那些事(2)----怎样支持RESTFul的HTTP Patch方法?
标签:host sdn img rri patch api png this pos
原文地址:http://www.cnblogs.com/mthoutai/p/6740039.html