我正在尝试使用 Google Apps Script 和 Google My Business Api 了解我们的位置。
获得评论和东西没什么大不了的。
该代码在 OAuth2 Playground 中运行良好。
这是请求:
var myBusinessService = getMyBusinessService();
var payload ={
"locationNames":["accounts/116447162401331885225/locations/10722475831894877870"],
"basicRequest": {
"metricRequests": [{
"metric": "ALL"
}],
"timeRange": {
"startTime": "2017-01-01T00:00:01.045123456Z",
"endTime": "2017-01-31T23:59:59.045123476Z"
}
}
};
var options = {
"headers":{
"Authorization": 'Bearer ' + myBusinessService.getAccessToken()
},
"method": "POST",
"payload": payload,
"muteHttpExceptions": true
};
var response = UrlFetchApp.fetch('https://mybusiness.googleapis.com/v4/accounts/116447162401331885225/locations:reportInsights', options);
响应:
{error={code=400, details=[Ljava.lang.Object;@3116fd89, message=Invalid JSON payload received. Unknown name "basicRequest": Cannot bind query parameter. 'basicRequest' is a message type. Parameters can only be bound to primitive types., status=INVALID_ARGUMENT}}
希望有人可以帮助我。
问候
蒂斯