title: Sending Messages On Google Hangouts Using Requests Returns Value Unpack Error
body: <p>I've been trying for a long time to send messages to Google Hangouts (<a href="https://hangouts.google.com" rel="nofollow noreferrer">https://hangouts.google.com</a>) using Python. Whenever you send a message, Google sends a POST request to
  <a href="https://chat-pa.cleints6.google.com/chat/v1/conversations/sendchatmessage" rel="nofollow noreferrer">https://chat-pa.cleints6.google.com/chat/v1/conversations/sendchatmessage</a> and I'm trying to use this endpoint to send my automated messages. For some reason though, Python gives me a &quot;Too many values to unpack error&quot; even though I've copied the request payload directly from the request.</p>
  <p>My code:</p>
  <pre class="lang-py prettyprint-override"><code>import requests, os
  
  headers = {}
  for header in open('headers.txt','r').read().split('\n'):
    h = header.split(':')
    if h[0] == 'cookie': headers['cookie'] = os.environ['cookie']
    elif h[0] == 'referer': headers['referer'] = 'https://hangouts.google.com/'
    elif h[0] == 'origin': 'https://hangouts.google.com'
    else: 
      if h[1][0] == ' ':
        headers[h[0]] = h[1][1:]
      else:
        headers[h[0]] = h[1]
        
  json = [
    [[44, 3, &quot;babel-chat.frontend_20220517.12_p0&quot;, 1652814971], [&quot;lcsw_hangouts_82D8803F&quot;, &quot;F7C7EF2859C749EF&quot;], [0], 'en'],
    None,
    None,
    None,
    [],
    None,
    None,
    [[&quot;Ugw4F8fT_hl0G3vKGNN4AaABAQ&quot;], &quot;410919038880&quot;, 2, [1], 1],
    None,
    None,
    None,
    [0, &quot;automate this message&quot;, [False, False, False, False]]
  ]
  
  r = requests.post('https://chat-pa.clients6.google.com/chat/v1/conversations/sendchatmessage?key=hangoutskey&amp;alt=protojson', headers=headers, data=json)
  print(r.json())
  </code></pre>
  <p><a href="https://i.stack.imgur.com/35xQH.png" rel="nofollow noreferrer">Image</a></p>
  <pre class="lang-py prettyprint-override"><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 30, in &lt;module&gt;
      r = requests.post('https://chat-pa.clients6.google.com/chat/v1/conversations/sendchatmessage?key=AIzaSyD7InnYR3VKdb4j2rMUEbTCIr2VyEazl6k&amp;alt=protojson', headers=headers, data=json)
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/api.py&quot;, line 117, in post
      return request('post', url, data=data, json=json, **kwargs)
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/api.py&quot;, line 61, in request
      return session.request(method=method, url=url, **kwargs)
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/sessions.py&quot;, line 515, in request
      prep = self.prepare_request(req)
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/sessions.py&quot;, line 443, in prepare_request
      p.prepare(
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/models.py&quot;, line 321, in prepare
      self.prepare_body(data, files, json)
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/models.py&quot;, line 517, in prepare_body
      body = self._encode_params(data)
    File &quot;/home/runner/Chat-messages/venv/lib/python3.8/site-packages/requests/models.py&quot;, line 99, in _encode_params
      for k, vs in to_key_val_list(data):
  ValueError: too many values to unpack (expected 2)
  </code></pre>
  <p>Does anyone have any solutions or similar experience to this problem? Anything would help.</p>