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.
Please see my answer here .
Make use of the google client api for javascript.
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