QPX Express API 400错误 - 无效输入:收到空请求

时间:2016-11-11 09:29:00

标签: json coldfusion

我搜索得很远。我至少不是JSON基金会,所以如果可以,请提供帮助。

我正在使用带有Coldfusion的QPX API并尝试执行简单的请求并返回结果。

到目前为止我的内容如下:

<cfset qpxFields ='
{
  "request": {
    "passengers": {
      "adultCount": "1"
    },
    "slice": [
      {
        "origin": "SFO",
        "destination": "LAX",
        "date": "2014-09-19"
      }
    ],
    "solutions": "1"
  }
}'>



<cfhttp url="https://www.googleapis.com/qpxExpress/v1/trips/search?key=YOUR_KEY" method="post" result="httpResp" timeout="60">
    <cfhttpparam type="header" name="Content-Type" value="application/json" />
    <cfhttpparam type="body" value="#serializeJSON(qpxFields)#">
</cfhttp>

<cfoutput>
#httpResp.FileContent#
</cfoutput>

我收到以下错误:

{ "error": { "errors": [ { "domain": "global", "reason": "badRequest", "message": "Invalid inputs: received empty request." } ], "code": 400, "message": "Invalid inputs: received empty request." } }

如果我输出变量qpxFields,我得到:

{ "request": { "passengers": { "adultCount": "1" }, "slice": [ { "origin": "SFO", "destination": "LAX", "date": "2014-09-19" } ], "solutions": "1" } }

1 个答案:

答案 0 :(得分:0)

发现问题。变量qpxFields不应该用引号括起来。

S