playlistItems.insert failing in Node.js googleapi youtube

I am uploading a video to Youtube and then attempting to add it to a playlist. The playlist insert is failing in a weird way. Here is my code:

var options = {
                    'part'  : 'snippet',
                    'snippet'   : {
                        'playlistId'    : playlistId,
                        'resourceId'    : {
                            'kind'      : 'youtube#video',
                            'videoId'   : videoId
                        }
                    },
                    status  : {
                        privacyStatus   : 'unlisted'
                    }
                };

            console.log('options : ' + JSON.stringify(options));

            youtube.playlistItems.insert(options, function(listErr, listResponse){

                console.log(JSON.stringify(listErr));
                console.log(JSON.stringify(listResponse));

            });

I always get the exact same response:

{"errors":[{"domain":"youtube.playlistItem","reason":"playlistIdRequired","message":"Playlist id not specified."}],"code":400,"message":"Playlist id not specified."}

Anyone have any idea what I'm doing wrong? Any help will be much appreciated. I'm using googleapi Node.js sdk.

I was having a similar issue and inspected the source code and realised that the body of an API call should be under options.resource property. So your options object should look like the following:

var options = {
    "part"  : "snippet",
    "resource" : {
        "snippet" : {
            "playlistId" : playlistId,
            "resourceId" : {
                "kind" : "youtube#video",
                "videoId" : videoId
                }
            }
        }
    }

Also note that I've changed the object to use double-quotation marks, as options.resource is expected to be valid JSON. I've also removed the status property as it is not listed as a parameter on the API reference page - https://developers.google.com/youtube/v3/docs/playlistItems/insert