QPX Express API返回400解析错误 [英] QPX Express API is returning 400 parse error
问题描述
我想使用Google QPX Express API中的数据,而我正在尝试设置一个非常基本的请求。
在demopage [1]上我复制了生成的JSON,如下所示:
I'd like to consume data from the Google QPX Express API and I'm trying to setting up a very basic request. On the demopage [1] I copied the generated JSON which looks as follows:
{
"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
}
}
根据在线手册[2]基本请求具有以下结构:
According to the Online Manual [2] a basic request has the following structure:
https://www.googleapis.com/qpxExpress/v1/trips/search?key=your_API_key_here
所以我使用我在谷歌开发者控制台生成的API密钥插入了这段代码,但是重新
So I inserted this code using my API key which I generated in the google developers console, but the re
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
我的请求有什么问题?
[1] https://qpx-express-demo.itasoftware.com/
[2] https://developers.google.com/qpx-express/v1/requests
推荐答案
您需要在请求中为Content-TypeHTTP标头指定值。在你的情况下application / json:
You need to specify a value for "Content-Type" HTTP header in your request. In you case "application/json" :
Content-Type:application / json
Content-Type: application/json
这篇关于QPX Express API返回400解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!