无法访问本地主机上的 API 资源管理器 [英] Cannot access API explorer on localhost

查看:30
本文介绍了无法访问本地主机上的 API 资源管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建 Endpoints 应用程序,但我是 Google App Engine 的新手.

I'm trying to build an Endpoints application, but am new to Google App Engine.

据我所知,SDK 中包含某种 API Explorer 应该让我测试/验证我的 API——文档说:通过导航到 http 在 Google APIs Explorer 中测试 API 后端://localhost:8080/_ah/api/explorer".但是我找不到任何关于 API Explorer 实际上是什么、做什么或看起来像什么的文档.

As I understand it, there's some kind of API Explorer included in the SDK that should let me test/verify my API -- the docs say: "Test the API backend in the Google APIs Explorer by navigating to http://localhost:8080/_ah/api/explorer". But I can't find any documentation of what API Explorer actually is, does, or looks like.

无论如何,当我尝试点击该 URL 时,我会立即被重定向到 https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/,其中没有告诉我任何有用的信息,而且似乎一定是某种错误.

In any case, when I try to hit that URL, I get immediately redirected to https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/, which tells me nothing useful, and seems like it must be an error of some kind.

devappserver 日志说:

The devappserver logs say:

INFO     2013-07-17 17:27:54,574 server.py:593] default: "GET /_ah/api/explorer HTTP/1.1" 302 -
INFO     2013-07-17 17:27:56,099 server.py:593] default: "GET /_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.7JUwNUXMAS8.O%2Fm%3D__features__%2Fam%3DEQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTO0dpKS_pssf5r3z87E6FlFvDGdOg HTTP/1.1" 200 1933
INFO     2013-07-17 17:27:56,193 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO     2013-07-17 17:27:56,492 server.py:593] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 200 576
INFO     2013-07-17 17:27:56,507 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO     2013-07-17 17:27:56,583 server.py:593] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2342
INFO     2013-07-17 17:27:56,811 server.py:593] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 200 576
INFO     2013-07-17 17:27:56,886 server.py:593] default: "GET /_ah/api/discovery/v1/apis/scrnxSync/v1/rest HTTP/1.1" 200 3365

为了任何值得的东西.

这是我的 app.yaml:

Here's my app.yaml:

application: scrnx-cloud-1
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /admin/.*
  script: admin.application
  login: admin
  secure: always

  # Endpoints handler
- url: /_ah/spi/.*
  script: sync_api.application

  # catchall - must come last    
- url: /.*
  script: default.application


admin_console:
  pages:
  - name: View Measurement
    url: /admin/measurement  


libraries:
- name: jinja2
  version: 2.6
- name: markupsafe
  version: 0.15

builtins:
- admin_redirect: off
- appstats: off
- deferred: off
- remote_api: on

我还应该做些什么来设置它?

Is there something else I'm supposed to be doing to set this up?

推荐答案

API Explorer 的 URL 是正确的,但存在一些问题(显然不是全部解决)API Explorer 没有正确列出您的 API.

The URL for the API Explorer is correct, but there have been some issues (apparently not all resolved) where the API Explorer doesn't correctly list your APIs.

作为其外观的比较 https://developers.google.com/apis-explorer/ 是 Google API 的 API Explorer,比您通常自己托管的 API 多得多,但只是为了让您了解您应该看到的内容:点击后每个 API 的 API 列表和详细信息.

As comparison of how it should look like https://developers.google.com/apis-explorer/ is the API Explorer for Google APIs, far more APIs than you would normally host yourself, but just to give you an idea of what you should see: a list of APIs and details for each API once you click on it.

通常有效的解决方法是将 API 的名称和版本显式添加到 URL,因此由于您的 API 被称为 scrnxSync,版本为 v1,因此此链接应该向您展示您为 API 定义的方法,并允许您调用这些方法:

A workaround that usually worked is to explicitly add the name and version of your API to the URL, so since your API is called scrnxSync with version v1 this link should show you the methods you defined for your API, and allow you to call those methods:

https://developers.google.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/scrnxSync/v1/

这篇关于无法访问本地主机上的 API 资源管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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