Bad request API google Python
Question: I was getting usually send the request by the code below, but out of nowhere
he started the mistake and do not want to send. Could anyone help 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
    


Answer: The 400 error will return information what is incorrect:

> Invalid inputs for request id \"nL8TcZS7RG7DPB70m0MNw9\": Brl 200.00 is not
> a valid value for x.maxPrice."

In this case the space is causing the trouble. Replace

    
    
    BRL 200.00
    

with

    
    
    BRL200.00
    

Link to documentation for [maxPrice](https://developers.google.com/qpx-
express/v1/trips/search)

