【问题标题】:App Engine Cloud Endpoint Javascript library does not workApp Engine Cloud Endpoint Javascript 库不起作用
【发布时间】:2013-05-29 05:13:41
【问题描述】:

我尝试通过 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","re​​ason":"notFound","message":"Not Found"}],"code":404,"message ":"未找到"}}

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,现在可以使用了。该文档对不同的事物使用相同的术语“your-app-id”。真的让我很困惑。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 1970-01-01
    • 2017-04-11
    • 2015-01-12
    • 2019-09-15
    • 2020-01-12
    • 1970-01-01
    相关资源
    最近更新 更多