Post a comment on Youtube channel video via api using Python

1.7k Views Asked by At

I have a channel id and i have a video id. How can I post a comment on that channel video via API. I have following snippets:

url = 'https://gdata.youtube.com/feeds/api/videos/'+str(entity)+'/comments'
values = { 'Content-Type': 'application/atom+xml','Content-Length' :len(str(message)),'Authorization': str(access_token),'GData-Version' : 2 , 'X-GData-Key': 'AIzaSyApCAE4SbaCtSOAKayxMS6qFNNWbtzhhSo'}
data = urllib.urlencode(values)
req =  urllib2.Request(url, data,method='POST')
req.add_header('Accept', 'application/json')
response = urllib2.urlopen(req)
result = response.read()
print (result)

It gives the following error.

HTTP 415 Error: Unsupported Media Type

I have been stuck here for a few days. Please help me out. I also read the following thread. I provided the links below.

https://developers.google.com/youtube/2.0/developers_guide_protocol_comments#Retrieve_comments, https://developers.google.com/youtube/articles/changes_to_comments#create-comments

Thanks in advance.

1

There are 1 best solutions below

0
On

v2 is deprecated and Comments feature in Data API v3 will soon be released. Here's the tracker: https://code.google.com/p/gdata-issues/issues/detail?id=5046