Search code examples
pythonyoutubeyoutube-apiyoutube-livestreaming-api

YouTube send live chat message does not work


youtube.liveChatMessages().insert returns with 400 error code, reason unexpectedPart.

This is the same reponse received on the Google API explorer.

def send_message(youtube):
  send_message_response = youtube.liveChatMessages().insert (
     part = "snippet",
     body = dict (
        snippet = dict(
           liveChatId = result_chatId,
           type = "textMessageEvent",
           textMessageDetails = dict(
               messageText = "hello world"
           )
         ),
         authorDetails = dict(
             displayName = "blabla"
         )
      )
   ).execute()

   print "%s" % (send_message_response)

Error response received.

Error Response


Solution

  • I'm pretty sure that the authorDetails resource is a dictionary returned from the API which gives details about the author of the chat message. It is only returned from GET requests and should never be added as a parameter on a POST or PUT request, as this data can't be changed.