尽管已启用帐单,但Google API密钥仍达到最高请求限制 [英] Google API Key hits max request limit despite billing enabled

查看:528
本文介绍了尽管已启用帐单,但Google API密钥仍达到最高请求限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信我已经尽了一切努力来正确设置对Distance Matrix API的访问权限。

首先,我创建了一个项目和一个结算帐户。该计费帐户已在此项目中启用。



接下来,我启用了距离矩阵API并创建了一个不受限制的(现在)API密钥。 b

这就是我拨打Google Distance Matrix API的方式:

  var requestUri = string .Format( https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}&destinations={1}&KEY={2} ,originAddress,destinationAddress,apiKey); 
var request = WebRequest.Create(requestUri);
var response = request.GetResponse();
return XDocument.Load(response.GetResponseStream());

然后解析从这个方法返回的XDocument,并且我要求计算的距离是提取。



然而,在2500次请求之后,我收到一个 OVER_QUERY_LIMIT 这个消息:



您已超出此API的每日请求限额。我们建议您在Google Developers Console上注册一个密钥:https://console.developers.google.com/apis/credentials?project = _



我是否忽略了设置API密钥或项目/结算帐户的任何步骤?或者任何人都可以看到我在我的代码中做错了什么?

解决方案

KEY = 需要小写 key =

  var requestUri = string .Format(https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0} 
& destinations = {1}& KEY = {2},originAddress,destinationAddress,apiKey);

应该是:

  var requestUri = string.Format(https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0} 
& amp ; destinations = {1}& key = {2},originAddress,destinationAddress,apiKey);


I believe I have done everything to properly setup access to the Distance Matrix API.

First, I created a project and a billing account. That billing account is enabled on this project.

Next, I enabled the Distance Matrix API and created an unrestricted (for now) API key.

This is how I am making calls to the Google Distance Matrix API:

var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}&destinations={1}&KEY={2}", originAddress, destinationAddress, apiKey);
var request = WebRequest.Create(requestUri);
var response = request.GetResponse();
return XDocument.Load(response.GetResponseStream());

The XDocument that is returned from this method is then parsed and the distance I am requesting to be calculated is extracted.

However, after 2500 requests, I am receiving an OVER_QUERY_LIMIT with this message:

You have exceeded your daily request quota for this API. We recommend registering for a key at the Google Developers Console: https://console.developers.google.com/apis/credentials?project=_

Have I overlooked any steps in setting up the API key or project/billing account? Or can anybody see something I am doing wrong in my code?

解决方案

KEY= needs to be lowercase key=

var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}
                                &destinations={1}&KEY={2}", originAddress, destinationAddress, apiKey);

should be:

var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}
                                &destinations={1}&key={2}", originAddress, destinationAddress, apiKey);

这篇关于尽管已启用帐单,但Google API密钥仍达到最高请求限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆