Python Traceback Error
Question: Unable to create a response with this api.I am unable to call the function
locu_search('new york'). I get the following error shown below. I am using
Komodo as my IDE, this started when I created a new python shell.

    
    
    import urllib2
    import json
    
    local_api = '0d5897aae41eeafbd62ad0815af15cc42b2ed7c0'
    
    def locu_search(query):
    api_key = local_api
    url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key
    locality = query.replace('','%20')
    final_url = url + "&locality=" + locality + "&category=restaurant"
    json_obj = urllib2.urlopen(final_url)
    data = json.load(json_obj)
    
    for item in data['objects']:
        print item['name'],item['phone']
    
      locu_search('new york')
    

The error is listed below:

    
    
      **Traceback (most recent call last):
      File "<console>", line 0, in <module>
      File "<console>", line 0, in locu_search
      File "c:\python27\lib\urllib2.py", line 154, in urlopen
      return opener.open(url, data, timeout)
      File "c:\python27\lib\urllib2.py", line 437, in open
     response = meth(req, response)
     File "c:\python27\lib\urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
     File "c:\python27\lib\urllib2.py", line 475, in error
     return self._call_chain(*args)
     File "c:\python27\lib\urllib2.py", line 409, in _call_chain
     result = func(*args)
     File "c:\python27\lib\urllib2.py", line 558, in http_error_default
     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
     HTTPError: HTTP Error 400: BAD_REQUEST**
    


Answer: 400 Bad Request should give you a headsup about the problem , this is
basically due to a malformed request and I strongly suspect the culprit is in
th line `url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key` ,
check if `api_key` token is invalid or no longer valid.

