i getting send request code below, out of started mistake , not want send. me?
the code:
import urllib2 import json url = "https://www.googleapis.com/qpxexpress/v1/trips/search?key=aizasybtrcsb8tz7u0f9u6txjemwmcyrdj9b4b8" code = { "request": { "passengers": { "adultcount": 1, "childcount": 1, "infantinseatcount": 1 }, "slice": [ { "origin": "ssa", "destination": "rec", "date": "2015-05-01", "maxstops": 1, "permitteddeparturetime": { "earliesttime": "09:00", "latesttime": "16:00" } }, { "origin": "rec", "destination": "ssa", "date": "2015-05-20", "maxstops": 1 } ], "maxprice": "brl 200.00", "refundable": "false", "solutions": 20 } } jsonreq = json.dumps(code, encoding = 'utf-8') req = urllib2.request(url, jsonreq, {'content-type': 'application/json'}) flight = urllib2.urlopen(req) response = flight.read() flight.close() print(response)
the error:
traceback (most recent call last): file "c:\users\francisco\desktop\projeto\test1.py", line 41, in <module> flight = urllib2.urlopen(req) 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
the 400 error return information incorrect:
invalid inputs request id \"nl8tczs7rg7dpb70m0mnw9\": brl 200.00 not valid value x.maxprice."
in case space causing trouble. replace
brl 200.00
with
brl200.00
link documentation maxprice