Here’s the request I’m attempting:
https://developers.google.com/youtube/2.0/developers_guide_protocol_playlists#Deleting_a_playlist
Here’s the request that is failing:
$.ajax( {
dataType : 'json-p',
type : 'DELETE',
url : 'https://gdata.youtube.com/feeds/api/users/default/playlists/' + playlist_id + '?access_token=' + hash_values_json.access_token + '&alt=json',
headers : {
'Access-Control-Allow-Origin': '*',
'contentType': "application/atom+xml",
'GData-Version': '2',
'X-GData-Key': 'key=' + dev_Key },
success : function(response) {
},
error : function() {
alert("Delete of playlist failed."); }
}
);
Here is the feedback from Chrome-Tools indicating the request is being sent as an OPTIONS request and more information:
https://i.stack.imgur.com/iQzjy.png
In the javascript console, I’m receiving the following error:
OPTIONS https://gdata.youtube.com/feeds/api/users/default/playlists/760354511254461C?access_token=ya29.AHES6ZS51Dqs8F8CwkWq23LgevXCD7tWSJLVCLEBxEW22a2zNSY8OCxr 405 (Method Not Allowed)
XMLHttpRequest cannot load https://gdata.youtube.com/feeds/api/users/default/playlists/760354511254461C?access_token=ya29.AHES6ZS51Dqs8F8CwkWq23LgevXCD7tWSJLVCLEBxEW22a2zNSY8OCxr. Origin http://localhost:3000 is not allowed by Access-Control-Allow-Origin.
Found out that it’s not possible to do cross domain POST/DELETE requests with JQuery AJAX yet (GET requests are okay however). How I got around the problem is sending a request to my server to perform the Youtube DELETE request.