title: Error 400 Bad Request when accessing Twitch API from Python 3.8
body: <p>This is my code for my Discord bot to access Twitch API and see if any streamers in the &quot;Twitch_channels.txt&quot; document are live. It worked well for a while but then I started getting this error:</p>
  <pre><code>Ignoring exception in on_ready
  Traceback (most recent call last):
    File &quot;C:\Users\GAMING-PC\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py&quot;, line 343, in _run_event
      await coro(*args, **kwargs)
    File &quot;C:\Users\GAMING-PC\Documents\Discord bot\Discord-bot\SAMURAI.py&quot;, line 75, in on_ready
      await onlinecheck(onlines)
    File &quot;C:\Users\GAMING-PC\Documents\Discord bot\Discord-bot\SAMURAI.py&quot;, line 54, in onlinecheck
      if len(stream_data['data']) == 1:
  KeyError: 'data'
  </code></pre>
  <p>This is the code, it takes the names from a text document and then accesses Twitch API to see if that channel is live or not:</p>
  <pre class="lang-py prettyprint-override"><code>async def onlinecheck(onlines):
      check = False
      if check == False:
          channels = open('Twitch channels.txt')
          lines = channels.readlines()
          for line in lines:
              entry = line.split(',')
              server = client.get_channel(int(entry[0]))
              channel = str(entry[1])
              client_id = 'k6hsyhu5xdr78uwtloku6slque6sxj'
              client_secret = 'secret goes here'
              streamer_name = channel
              body = {
                  'client_id': client_id,
                  'client_secret': client_secret,
                  &quot;grant_type&quot;: 'client_credentials'
              }
              r = requests.post('https://id.twitch.tv/oauth2/token', body)
              keys = r.json();
              headers = {
                  'Client-ID': client_id,
                  'Authorization': 'Bearer ' + keys['access_token']
              }
              stream = requests.get('https://api.twitch.tv/helix/streams?user_login=' + streamer_name, headers=headers)
              stream_data = stream.json()
              print(stream_data)
              if len(stream_data['data']) == 1:
                  if channel not in onlines:
                      embed = discord.Embed(title=f&quot;{channel} is streaming!&quot;,description=f&quot;[link](https://www.twitch.tv/{channel})&quot;)
                      await server.send(embed=embed)
                      onlines.append(channel)
              else:
                  if channel in onlines:
                      onlines.remove(channel)
              check = True
      await asyncio.sleep(240)
      check = False
  </code></pre>
  <p>When I print the <strong>stream_data</strong> it prints this:</p>
  <pre><code>{'error': 'Bad Request', 'status': 400, 'message': 'Malformed query params.'}
  </code></pre>
  <p>I don't know if it's something on my side as this worked before, or if it's something to do with the API.</p>