根据手册,我不知道如何使用body向Google API建立请求: https://developers.google.com/my-business/content/insight-data https://cloud.google.com/blog/products/maps-platform/introducing-insights-in-google-my
简单的请求有效,但我不知道如何编写正文部分(如上述url)。
{
"locationNames": [
“accounts/account_name/locations/locationId”,
],
“basicRequest” : {
"metricRequests": [
{
"metric": QUERIES_DIRECT,
},
{
"metric": QUERIES_INDIRECT,
}
],
"timeRange": {
"startTime": 2016-10-12T01:01:23.045123456Z,
"endTime": 2017-01-10T23:59:59.045123456Z,
},
},
}
insights.url = paste0('https://mybusiness.googleapis.com/v4/',account.id,'/locations:reportInsights')
req <- POST(
url = insights.url,
body = toJSON(args, auto_unbox=TRUE),
add_headers(Authorization = paste("Bearer", token, sep = " "))
)