“NetworkError: 405 Method Not Allowed” on Google contact delete

依然范特西╮ 提交于 2019-12-08 03:02:29

问题


I am trying to delete a Google Contact through javascript. As per v3 of Google Contacts api I have defined:

scope to https://www.google.com/m8/feeds

And authenticated user, and got the access_token. And as per the v3 documentation on this page, trying to delete a contact like this:

$.ajax({
url: 'https://www.google.com/m8/feeds/contacts/default/full/temp123info@gmail.com?access_token=ya29.AHES6ZQoqUgoYmDzXyo-WsSlKv1-_2D_HzmXuH-wBuTR3e1ADxO0VWM',
type: 'DELETE',
success: function(res)
{
    console.log(res);
},

error: function(error)
{
    console.log(error);
}
}); 

Getting this error:

   "NetworkError: 405 Method Not Allowed - https://www.google.com/m8/feeds/contacts/laiquedaudpota43@gmail.com/full/temp123info@gmail.com?access_token=ya29.AHES6ZQoqUgoYmDzXyo-WsSlKv1-_2D_HzmXuH-wBuTR3e1ADxO0VWM"

Any help would be appreciated. Thanks.


回答1:


Please see my answer here .

Make use of the google client api for javascript.




回答2:


You are experiencing something called CORSS (Cross-Origin XMLHttpRequest)

if you open chrome dev tools you will see that the browser ignored your 'delete' type and sent OPTIONS instead.

this is happening when you try to call a server from other origin, the browser will fire an extra request with data type OPTIONS to the server to know what is required in order to send your original delete post.
The problem is that the server is not allowing 'OPTIONS' method type. if you ask me, ill try to find proxy (jsonp) service for google contact . or an api

Please have a look here: https://developers.google.com/api-client-library/javascript/start/start-js

I think you should use their standard api for that.



来源:https://stackoverflow.com/questions/19675835/networkerror-405-method-not-allowed-on-google-contact-delete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!