insert video into a playlist with youtube api v3

youtube, youtube-api

Solution

Your `resourceId` isn't complete, as it doesn't identify to the API how to interpret the `videoId` parameter. Try setting the `kind` attribute of the `resourceId`, like this:

  "snippet": {
    "playlistId": "PL8hD12HFC-nuswc21_e64aPAy9B25sEH7",
    "resourceId": {
      "kind": "youtube#video",
      "videoId": "KMGuyGY5gvY"
    }
  }

That way, the API will know in which 'domain' (so to speak) to locate the resource identified by the string you send in.

Problem

Hey so I am fairly familiar to the youtube api .. I know how to read channels and playlist along with getting any relevant video information I identify as Important I'm using php to do all of this but in order to make sure I have the correct idea of how each request/response works I attempted it in the browser with the API explorer Now I am trying to insert videos into a playlist I just created (also through the API) but I am having some trouble figuring out exactly how my request is not properly formed Here's The request ``` POST https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key={YOUR_API_KEY} Content-Type: application/json Authorization: Bearer ya29.1.AADtN_WT2TRZzH1t86nVlX26z9WPp-gnDTxVHGvdQ6xx0vyTzmkYeXkLdJerwllLzF_a X-JavaScript-User-Agent: Google APIs Explorer { "snippet": { "playlistId": "PL8hD12HFC-nuswc21_e64aPAy9B25sEH7", "resourceId": { "videoId": "KMGuyGY5gvY" } } } ``` here is the response ``` 400 Bad Request - Show headers - { "error": { "errors": [ { "domain": "youtube.playlistItem", "reason": "invalidResourceType", "message": "Resource type not supported." } ], "code": 400, "message": "Resource type not supported." } } ``` the playlist is an empty publicly viewable playlist I created using the API Explorer and is viewable through standard youtube website. The video is randomly selected off of youtube ... tried a few as thought it might be a specific problem with a video but no luck .. I have switched on OAuth and am using an account that is a verified youtube partner However I can seemed to figure out why the resource type is not supported I've looked around the web along with answers to the left without finding exactly what I am doing wrong.. any help with this problem would be greatly appreciated as I am kind of stuck at the moment

Original source