17

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

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.

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.

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

for whatever that's worth.

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?

c roald
  • 1,984
  • 1
  • 20
  • 30

11 Answers11

8

Something changed, and now you must start Chrome in a specific way to use api explorer on localhost development server

here is a link to info from google.

But for me it still didn't fix using api explorer with localhost dev server.
I find that a possible workaround is to launch Chrome with the flag "--allow-running-insecure-content"
On MacOs in terminal run this:

/Applications/Google\ Chrome.app/Contents/Mac/Google\ Chrome --user-data-dir=test --allow-running-insecure-content

Przemek Lada
  • 111
  • 1
  • 4
7

If you are using Chrome browser, just make https in the URL to http. It worked for me.

http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/

A Paracha
  • 904
  • 8
  • 9
4

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.

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.

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/

Scarygami
  • 15,009
  • 2
  • 35
  • 24
  • That link worked for me (tho with port 8888 and my API name). Why doesn't localhost:8888/_ahi/api redirect me? It just gives me 404. I only used GPE to generate the endpoint library from my endpoint class. Works fine deployed to GAE. The Explorer directly off the appstore url works for me. – Skystrider Jan 13 '16 at 22:09
4

I tried all of the above in chrome and nothing works for me, but using firefox I just click in the lock at the left of the url bar and disable the security. That made the trick for me, cheers !! :D

Phoenix
  • 1,329
  • 2
  • 12
  • 20
Andrés Muñoz
  • 225
  • 2
  • 10
3

A quick fix: Open the link: http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/ in firefox , then click the secure connection icon on the nav bar, then click disable protection. You should be able to see your APIs

ps; Remember to edit 8080 with your port number

Jasper Kinoti
  • 501
  • 3
  • 9
2

I'm also new to GAE Endpoints, and I had the same problem. In my case, I had this error because of the order of the url handlers in the app.yaml. I had it like this:

- url: /.*
  script: core_service.application

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

The right way is defining first the most specific routes and at the end the most general (/.*). Like this:

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

- url: /.*
  script: core_service.application
juanesarango
  • 560
  • 9
  • 17
  • 1
    I have trying everything beneath the sun, and this just works thanks man, this and unlock security using firefox clicking the lock at the left of url bar. – Andrés Muñoz Apr 04 '16 at 00:48
2

I know it is not exactly the same problem but I was having the message "You are exploring an API that is described or served via HTTP instead of HTTPS. This is insecure and may be blocked by your browser. To fix this, set up a TLS proxy for your API. Alternatively, you can tell your browser to allow active content via HTTP at this site (on Chrome, click the shield in the URL bar), but this will not improve security or dismiss this message."

Clicking the shield icon in the address bar of Chrome did it for me.

Maxime T
  • 848
  • 1
  • 9
  • 17
1

If you are running the AppEngine from GWT DevMode you need to change port in the base parameter to match what you see in console, for me that's 8888:

http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8888/_ah/api#p/

Jaroslav Záruba
  • 4,694
  • 5
  • 39
  • 58
0

For me, it is a very simple typo in app.yaml. If you have the same problem, it can be just this simple:

Instead of (which is correct):

- url: /_ah/spi/.*
  script: services.application

I put:

- url: /_ah/api/.*
  script: services.application

Changing api back to spi did the trick.

Nathan Do
  • 1,985
  • 19
  • 24
  • it is not a typo. from [docs](https://cloud.google.com/appengine/docs/python/endpoints/test_deploy#troubleshooting_a_deployment_failure): `Note: In the following table on backend configuration and deployment issues, we refer to the path /_ah/spi, which you might think is a typo, because applications send their requests to /_ah/api. However, the Endpoints backend actually handles these requests at the path /_ah/spi.` – Murat Ozgul Jan 18 '16 at 03:08
0

The problem is that your python file can't find the import for:

from protorpc import remote

Therefore use the terminal, skip the GUI, navigate to the appengine sdk directory and put your project in there. For mac it is:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/
0

I was having the same issue but it turned out that I was specifying the wrong port on localhost. When the dev server(s) start up the log specifies three discreet ports on localhost:

INFO 2015-07-26 03:46:56,023 api_server.py:172] Starting API server at: http:// localhost:35714

INFO 2015-07-26 03:46:56,027 dispatcher.py:186] Starting module "default" running at: http:// localhost:8080

INFO 2015-07-26 03:46:56,028 admin_server.py:118] Starting admin server at: http:// localhost:8000

The issue was that I was trying to use the port for the api server but you need to just use the port for the default module.

This works: http:// localhost:8080/_ah/api/explorer (I needed to click the shield in chrome and allow unsafe scripts because the url is unencrypted)

Community
  • 1
  • 1
Vaughn
  • 123
  • 1
  • 8