17
votes

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?

11

11 Answers

4
votes

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/

8
votes

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

7
votes

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/

4
votes

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

3
votes

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

2
votes

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
2
votes

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.

1
votes

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/

0
votes

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.

0
votes

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
votes

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)