title: Google app script Youtube service fails to insert live chat message
body: <p>I wrote a function to insert a message in a youtube live chat using Youtube service in google app script. However the function throws an error</p>
  <pre><code>GoogleJsonResponseException: API call to youtube.liveChatMessages.insert failed with error: Request contains an invalid argument. at InsertLiveChatMessage (Code:122:41) at __GS_INTERNAL_top_f...
  </code></pre>
  <p>This is the function that I've tried running from the editor</p>
  <pre><code>function InsertLiveChatMessage(live_chat_id=&quot;Cg0KC0N5XzYtX1hVVy1jKicKGFVDdDR0LWplWTg1SmVnTWxaLUU1VVd0QRILQ3lfNi1fWFVXLWM&quot;, message=&quot;message&quot;)
  {
    let response = {};
    let resource = {
      &quot;snippet&quot;: {
        &quot;liveChatId&quot;: live_chat_id,
        &quot;type&quot;: &quot;textMessageEvent&quot;,
        &quot;textMessageDetails&quot;: {
          &quot;messageText&quot;: message
        }
      }
    };
  
    try
    {
      response = YouTube.LiveChatMessages.insert(resource, &quot;snippet&quot;);
    }
    catch(e)
    {
      response[&quot;error&quot;] = &quot;Something went wrong&quot;;
    }
  
    console.log(response);
  }
  </code></pre>
  <p>I had enabled Youtube data api service and granted permissions before running the above function. I borrowed resource object from Google API explorer. Can someone point if it a google app script problem or something to do with my code.</p>