获取帐户列表时出现RATE_LIMIT_EXCEEDED异常(Google My Business API)



如今,我们正在为我们的平台实现My Business api集成。我遵循了这份文件";https://developers.google.com/my-business/content/prereqs"在我尝试获取帐户列表后,出现了一个错误;

<请求时出现HttpError 429https://mybusinessaccountmanagement.googleapis.com/v1/accounts?alt=json返回";超出了消费者"project_number:XXXX"的服务"mybusinessaccountmanagement.googleapis.com"的配额度量"请求数"和限制"每分钟请求数"的配额&";。详细信息:;[{'@type':'type.googleapis.com/google.rpc.ErrorInfo','reason':'RATE_LIMIT_EXCEEDED','domain':'googleapis.com','metadata':{'quota_mic':'mybusinessaccountmanagement.googleapis.com/default_requests','consumer':'projects/XXXX','quota_LIMIT':'DefaultRequestsPerMinutePerProject','service':'my businessaccountmanagements.googleapi.com'}]>

output = self.service.accounts().list().execute();

有人面临过这种类型的问题吗?

谨致问候。

您可以使用rateLimiter:

import com.google.api.client.json.GenericJson;
import com.google.common.util.concurrent.RateLimiter;

//requests per second
private static final RateLimiter rateLimiter = RateLimiter.create(5.0);

private static GenericJson executeWithRateLimiter(request,
RateLimiter rateLimiter) {
rateLimiter.acquire();
return request.execute();
}

最新更新