App Engine Cloud Endpoint Javascript库不起作用

时间:2013-05-29 05:13:41

标签: javascript google-app-engine google-cloud-endpoints

我尝试通过this document启用Cloud Endpoint。

在定义API并进行一些配置之后,最终可以通过API Explorer成功查看和执行API。

但是,我无法启用Javascript客户端:

<html>
  <script type="text/javascript">
    function init() {
      var ROOT = "https://my-app-id.appspot.com/_ah/api";
      gapi.client.load('my-app-id', 'v1', function() {
        gapi.client.bigquery.query({
          'start_date': '2013-05-01',
          'end_date': '2013-05-02',
          'metrics': ['impr']
        }).execute(function(resp) {
          console.log(resp);
        });
      }, ROOT);
    }
  </script>
  <script src="https://apis.google.com/js/client.js?onload=init"></script>
</html>

我注意到在Javascript执行期间请求失败了,但我无法弄清楚原因。

请求

https://my-app-id.appspot.com/_ah/api/discovery/v1/apis/my-app-id/v1/rpc?

响应

  

{“error”:{“errors”:[{“domain”:“global”,“reason”:“notFound”,“message”:“Not Found”}],“code”:404,“message “:”未找到“}}

1 个答案:

答案 0 :(得分:1)

使用您的API名称,而不是my-app-id。此外,请确保您的API已部署并投放。如果不是,这同样会导致404

请参阅google cloud endpoints discrepancy between documentation, and what works in my app了解相同的问题。