我正在尝试从我使用的名为FileMaker的数据库系统中请求Google Analytics(v4)API中的数据。到目前为止,我已经通过OAuth 2.0成功进行了身份验证,并收到了随请求发送的访问令牌。当我得到响应时,尽管它实际上是空白的。
我尝试过在使用和不使用JSON格式的情况下更改请求,并在最后删除跟踪元素,以防万一这些东西妨碍了工作。
系统发送如下请求:
请求URI: https://analyticsreporting.googleapis.com/v4/reports:batchGet
请求:
--header "Content-Type:application/json"
--header "Content-Length: 0"
--header "Authorization: Bearer ya29.GlvgBhlJpplgnDKAqQgOXXXXXXXXXXXJw6mYG4cb36GTSV_Sm_Qk-Yv22BeOBf1YvxZ50S5RaSPfl9eoW3xOEwWHRTPcKKUrCiOgSTZ6PrinlgGT4c2cHpfrXn9"
--data {
"reportRequests" :
[
{
"dateRanges" :
[
{
"endDate" : "2019-03-31",
"startDate" : "2019-03-31"
}
],
"metrics" :
[
{
"expression" : "ga.users"
}
],
"viewID" : "186256915"
}
]
}
--trace $$trace --dump-header $$header --show-error $$initerror
...其中$$ trace值是FileMaker中的变量,可以捕获各种响应。
我希望收到OAuth 2.0 Playground生成的响应:
HTTP/1.1 200 OK
Content-length: 862
X-xss-protection: 1; mode=block
X-content-type-options: nosniff
Transfer-encoding: chunked
Vary: Origin, X-Origin, Referer
Server: ESF
-content-encoding: gzip
Cache-control: private
Date: Tue, 02 Apr 2019 16:05:37 GMT
X-frame-options: SAMEORIGIN
Alt-svc: quic=":443"; ma=2592000; v="46,44,43,39"
Content-type: application/json; charset=UTF-8
{
"reports": [
{
"data": {
"rows": [
{
"metrics": [
{
"values": [
"8705"
]
}
]
}
],
"maximums": [
{
"values": [
"8705"
]
}
],
"minimums": [
{
"values": [
"8705"
]
}
],
"isDataGolden": true,
"totals": [
{
"values": [
"8705"
]
}
],
"rowCount": 1
},
"columnHeader": {
"metricHeader": {
"metricHeaderEntries": [
{
"type": "INTEGER",
"name": "ga:users"
}
]
}
}
}
]
}
我实际上得到的是:
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Vary: Origin
Vary: X-Origin
Vary: Referer
Content-Encoding: gzip
Date: Wed, 03 Apr 2019 14:56:24 GMT
Server: ESF
Cache-Control: private
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: quic=":443"; ma=2592000; v="46,44,43,39"
Transfer-Encoding: chunked
{}
任何人都可以弄清楚这里可能出了什么问题吗?我在编写JSON请求方面没有丰富的经验,但是其他API请求也可以正常工作,但是这个让我很沮丧。
谢谢!