Reputation: 3
params = urllib.urlencode(data)
headers = {"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain",
}
conn = httplib.HTTPConnection(self.base_url)
conn.request('GET', url, params, headers)
response = conn.getresponse()
response_data = response.read()
conn.close()
Using above code I am passing data to url
. When method is POST
every thing is fine. But Method is 'GET'
i am not getting any data in response.
But when i am trying
url_data = urllib.urlopen(url)
url_data.read()
Then I am getting proper result.What could be the reason? Thanks in advance.
Upvotes: 0
Views: 198
Reputation: 110438
When using "GET" , the parameters should be really placed along with the URL - the "body" argument (to which ou are passing "params") is only used in post requests - In other words, try this instead:
conn.request('GET', url + "?" + params, None, headers)
Upvotes: 1