I've had success with GET requests from Youtube API v3, but am having problems getting a POST version to work, for adding a video to a playlist. I've tried many combinations of things, like putting the key in the query string, the access token in either the query string or the header, json vs. jsonp, but still no luck.
I got it to work fine in the API Explorer but the request it prints out is just the basic pieces without the context code to make it work, so I'm guessing I'm messing something up in the implementation of calling the ajax post command. Here's what I'm doing:
var myAccessToken = "blahblah"; //from oauth2, works fine for other calls
$.ajax({
type: "POST",
url: "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&access_token=" + myAccessToken,
data: {
"snippet": {
"playlistId": "PLIjo1t8cDbpGhOJrgEgMGFMb-VtAus_x9",
"resourceId": {
"kind": "youtube#video",
"videoId": "KMGuyGY5gvY"
},
}
},
success: function(data, textStatus, request) {
console.log("in success of ajax call, data: ", data);
},
dataType: 'jsonp'
});
My current error is below. Not sure if I actually need a "filter selected" or if my syntax is just wrong somewhere.
Error 400:
domain: "youtube.parameter"
location: ""
locationType: "parameter"
message: "No filter selected."
reason: "missingRequiredParameter"
Any ideas to try?