BAD REQUEST 400, when trying to access JSON
<p>I've been working on a bot for <code>Discord</code> in <code>discord.py</code> (not related) and I'm trying to pull from a server so I can interpret it, however, I'm getting a</p>

<blockquote>
  <p>BAD REQUEST 400</p>
</blockquote>

<p>when trying to actually pull from the server. I've tried to add a header to specify it as a JSON but it won't work.</p>

<pre><code>await bot.say("Fetching data")
headers = {"Content-type": "application/json"}
url = 'http://jisho.org/api/v1/search/words?keyword=boushi'
response = requests.get(url, headers=headers).json()
await bot.say(response)
</code></pre>

<p>The <code>bot.say</code> is just repeating back to me the output.</p>

<p>I wouldn't use .json() at the end of the request, in case you want to check the status_code for a bad request first.</p>

<pre><code>response = requests.get(url, headers=headers)
if response.status_code == 200:
    print response.content
</code></pre>

<p>And if you want to do something with the dict you can use json.loads()</p>

<pre><code>foo = json.loads(response.content)
</code></pre>

python json python-requests