title: Sending HTTP GET request using urllib
body: <p>I am trying to send HTTP <strong>GET</strong> request using urllib/urllib2 with some data.</p>
  
  <p>If we set some value of data param in urllib2.urlopen(url, data) the request object is changed to send POST request instead of GET. </p>
  
  <p>Is there any way to achieve this? Standard or Hack?</p>
  
  <p>Code snippet,</p>
  
  <pre><code>import requests
  import urllib
  query = urllib.urlencode({'query':'["=", ["fact", "role"], "storage"]'})
  # using request object
  print 'Output 1.'
  response = requests.get("http://localhost:8082/v3/nodes", data=query)
  print response.json()
  print
  # using urllib object
  print 'Output 2.'
  resp =  urllib.urlopen('http://localhost:8082/v3/nodes', data=query)
  print resp.read()
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Output 1. 
  [{u'deactivated': None, u'facts_timestamp': u'2016-02-04T14:06:07.269Z', u'name': u'node_xx_11', u'report_timestamp': None, u'catalog_timestamp': u'2016-02-04T14:06:16.958Z'}, {u'deactivated': None, u'facts_timestamp': u'2016-02-04T14:06:05.865Z', u'name': u'node_xx_12', u'report_timestamp': None, u'catalog_timestamp': u'2016-02-04T14:06:13.614Z'}]
  
  Output 2.
  The POST method is not allowed for /v3/nodes
  </code></pre>
  
  <p>For the 
  References I have gone through,</p>
  
  <p><a href="https://docs.python.org/2/library/urllib2.html#urllib2.urlopen" rel="nofollow">https://docs.python.org/2/library/urllib2.html#urllib2.urlopen</a></p>
  
  <p><a href="https://docs.python.org/2/library/urllib2.html#urllib2.Request.add_data" rel="nofollow">https://docs.python.org/2/library/urllib2.html#urllib2.Request.add_data</a></p>
  
  <p>This is not the road block for me, as I am able to use requests module for sending the data with <strong>GET</strong> request type. Curiosity is the reason of this post.</p>