有人知道我如何使用Java向这个API发送请求吗?链接是Business Profile Performance API,但没有代码示例。我尝试的代码不正确:假设businessProfilePerformance是BusinessProfilePerformance
类型的变量,以通过其构建器初始化全局参数,并且还负责授权。
try {
BusinessProfilePerformance.Locations.GetDailyMetricsTimeSeries metricReport = businessProfilePerformance.locations()
.getDailyMetricsTimeSeries(locationName);
GetDailyMetricsTimeSeriesResponse response = metricReport.execute();
if (!response.isEmpty()) {
System.out.println("Response== " + response);
}
} catch (Exception e) {
System.out.println(e);
}
错误是
服务器响应异常:400错误请求
{
"code" : 400,
"details" : [ {
"@type" : "type.googleapis.com/google.rpc.BadRequest"
} ],
"errors" : [ {
"domain" : "global",
"message" : "Request contains an invalid argument.",
"reason" : "badRequest"
} ],
"message" : "Request contains an invalid argument.",
"status" : "INVALID_ARGUMENT"
}
谢啦,谢啦
1条答案
按热度按时间eoxn13cs1#
我找到答案了。我把它放在这里以防有人会想到:假设变量business_profile_performance是通过其构建器的初始化器全局参数,并且还负责认证。
变量 dailyMetric 可以是下图所示的指标之一: