I need to be able to “love” a specific video by ID through the new YouTube v3 API for an authenticated user. I follow the action / insert guide found here:
https://developers.google.com/youtube/v3/docs/activities/insert
This code sample is great for posting a newsletter on my channel, but when I try to change the body to form a similar statement, I continue to get a 400 error. Here is what Ive changed from the original example in which the dict body is set:
body = {}
body["snippet"] = dict(type='like')
body["contentDetails"] = dict(
like=dict(
resourceId=dict(
kind="youtube#video",
videoId='_M9khs87xQ8'
)
)
)
According to the following documentation, the fields seem to be configured correctly.
https://developers.google.com/youtube/v3/docs/activities
But I keep getting 400 HttpEror, for example,
<HttpError 400 when requesting https://www.googleapis.com/youtube/v3/activities?alt=json&part=snippet%2CcontentDetails returned "Bad Request">
Ive -, . ? ?
,
Jeff,
for item in youtube.channels().list(part='contentDetails', mine=True).execute().get('items', []):
playlists = item['contentDetails'].get('relatedPlaylists', {})
if 'likes' in playlists:
body = {
"snippet": {
"playlistId": playlists['likes'],
"resourceId": {
"kind": 'youtube#video',
"videoId": '_M9khs87xQ8'
}
}
}
youtube.playlistItems().insert(body=body, part='snippet').execute()