Q:

Unable to get response from post request

I am trying to make a POST request to https://www.apartments.com, but I am not able to get any response back. Here is what I have written so far:
import requests
payload = {'t': '13555 SW Jenkins Rd, Beaverton, OR 97005', 'l': [-79.55213, 40.3322]}
r = requests.post("https://www.apartments.com/services/geography/search/", data=payload)

print r.status_code
print r.text  # return null

A:

If you use simplejson you can convert the payload to JSON. Of course, you still need to worry about the content type in the headers, so I've added that as well:
>>> import requests
>>> from simplejson import dumps as D
>>> payload = {'t': '13555 SW Jenkins Rd, Beaverton, OR 97005', 'l': [-79.55213, 40.3322]}
>>> headers = {'content-type': 'application/json'}
>>> r = requests.post("https://www.apartments.com/services/geography/search/",
...                    data=D(payload),
...                    headers=headers)
>>> 
>>> print r.status_code
200
>>> print r.text
[{"ID":"mp0jdmj","Display":"13555 SW Jenkins Rd, Beaverton, OR 97005","GeographyType":8,"Address":{"City":"Beaverton","State":"OR","StreetName":"13555 SW Jenkins Rd"},"Location":{"Latitude":45.50167,"Longitude":-122.81654}}]
>>> 

