QPX Express API Returns 400 Parsing Errors

I would like to use data from the Google QPX Express API, and I'm trying to configure a very simple query. On demopage [1], I copied the generated JSON, which looks like this:

{ "request": { "slice": [ { "origin": "ZRH", "destination": "DUS", "date": "2014-12-02" } ], "passengers": { "adultCount": 1, "infantInLapCount": 0, "infantInSeatCount": 0, "childCount": 0, "seniorCount": 0 }, "solutions": 20, "refundable": false } } 

According to the online manual [2], the main request has the following structure:

 https://www.googleapis.com/qpxExpress/v1/trips/search?key=your_API_key_here 

So, I pasted this code using my API key, which I created in the Google Developer Console, but re

 { "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "code": 400, "message": "Parse Error" } } 

What happened to my request?

[1] https://qpx-express-demo.itasoftware.com/ [2] https://developers.google.com/qpx-express/v1/requests

+1
json rest post
Nov 27 '14 at 22:03
source share
2 answers

It turns out that something is wrong with POSTMAN (AddOn REST API for Chrome). I tried the same with curl:

i) I saved the JSON that I would pass to my request in a file called "request.json":

 { "request": { "slice": [ { "origin": "ZRH", "destination": "DUS", "date": "2014-12-02" } ], "passengers": { "adultCount": 1, "infantInLapCount": 0, "infantInSeatCount": 0, "childCount": 0, "seniorCount": 0 }, "solutions": 20, "refundable": false } } 

ii), then in the terminal I switched to the directory in which the newly created request.json file was created and launched (myApiKey clearly indicates my actual API key):

 curl -d @request.json --header "Content-Type: application/json" https://www.googleapis.com/qpxExpress/v1/trips/search?key=myApiKey 

It worked for me.

+1
Nov 28 '14 at 13:54 on
source share

You need to specify a value for the Content-Type HTTP header in the request. In your case, "application / json":

Content-Type: application / json

+1
Dec 30 '15 at 22:02
source share



All Articles