title: Curl post request returning 500 server error in python
body: <p>The following curl request works perfectly when I run it through Windows' CMD.</p>
  
  <pre><code>curl -XPOST -H"Content-Type:application/json" http://my_url:8082/druid/v2/sql/ -d "{\"query\":\"SELECT DISTINCT(event) FROM programs\"}"
  </code></pre>
  
  <p>I am trying to replicate the same call in python 3 using urllib.requests</p>
  
  <pre><code>import urllib.request
  
  values = {'query':'SELECT DISTINCT(event) FROM programs'}
  url = 'http://my_url:8082/druid/v2/sql'
  
  data = urllib.parse.urlencode(values).encode("utf-8")
  req = urllib.request.Request(url, data)
  req.add_header("Content-Type","application/json")
  response = urllib.request.urlopen(req)
  the_page = response.read()
  </code></pre>
  
  <p>However the python version is returning a Server Error</p>
  
  <pre><code>response = urllib.request.urlopen(req)
  File "C:\Python\Python35\lib\urllib\request.py", line 163, in urlopen
  return opener.open(url, data, timeout)
  File "C:\Python\Python35\lib\urllib\request.py", line 472, in open
  response = meth(req, response)
  File "C:\Python\Python35\lib\urllib\request.py", line 582, in http_response
  'http', request, response, code, msg, hdrs)
  File "C:\Python\Python35\lib\urllib\request.py", line 510, in error
  return self._call_chain(*args)
  File "C:\Python\Python35\lib\urllib\request.py", line 444, in _call_chain
  result = func(*args)
  File "C:\Python\Python35\lib\urllib\request.py", line 590, in 
  http_error_default
  raise HTTPError(req.full_url, code, msg, hdrs, fp)
  urllib.error.HTTPError: HTTP Error 500: Server Error
  </code></pre>
  
  <p>Can someone tell me what I'm doing wrong please?</p>