The app returned an error when the Google Cloud Endpoints server attempted to communicate with it
Question: Hi I'm new to Google App Engine and Cloud Endpoints.

I have an app engine that serves web application.

And I want to use it with Cloud Endpoints.

So I just added source codes from here:
<https://cloud.google.com/appengine/docs/python/endpoints/getstarted/backend/write_api>

But I cannot deploy app and get this error message:

    
    
    Checking if Endpoints configuration has been updated.
    07:13 AM Failed to update Endpoints configuration.  The app returned an error when the Google Cloud Endpoints server attempted to communicate with it.
    07:13 AM See the deployment troubleshooting documentation for more information: https://developers.google.com/appengine/docs/python/endpoints/test_deploy#troubleshooting_a_deployment_failure
    

And this is my source codes

    
    
    import endpoints
    from protorpc import messages
    from protorpc import message_types
    from protorpc import remote
    
    package = 'Hello'
    
    
    class Greeting(messages.Message):
      """Greeting that stores a message."""
      message = messages.StringField(1)
    
    
    class GreetingCollection(messages.Message):
      """Collection of Greetings."""
      items = messages.MessageField(Greeting, 1, repeated=True)
    
    
    STORED_GREETINGS = GreetingCollection(items=[
        Greeting(message='hello world!'),
        Greeting(message='goodbye world!'),
    ])
    
    
    @endpoints.api(name='helloworld', version='v1')
    class HelloWorldApi(remote.Service):
      """Helloworld API v1."""
    
      @endpoints.method(message_types.VoidMessage, GreetingCollection,
                        path='hellogreeting', http_method='GET',
                        name='greetings.listGreeting')
      def greetings_list(self, unused_request):
        return STORED_GREETINGS
    
      ID_RESOURCE = endpoints.ResourceContainer(
          message_types.VoidMessage,
          id=messages.IntegerField(1, variant=messages.Variant.INT32))
    
      @endpoints.method(ID_RESOURCE, Greeting,
                        path='hellogreeting/{id}', http_method='GET',
                        name='greetings.getGreeting')
      def greeting_get(self, request):
        try:
          return STORED_GREETINGS.items[request.id]
        except (IndexError, TypeError):
          raise endpoints.NotFoundException('Greeting %s not found.' %
                                            (request.id,))
    
    APPLICATION = endpoints.api_server([HelloWorldApi])
    

exactly same with tutorial

and my app.yaml

    
    
    application: my application id
    version: application version
    runtime: python27
    api_version: 1
    threadsafe: true
    
    handlers:
    - url: /data
      script: MLP.app
      login: admin
    - url: /insert_db
      script: MLP.app
      login: admin
    - url: /validete
      script: MLP.app
      login: admin
    - url: /stylesheets
      static_dir: stylesheets
    - url: /js
      static_dir: js 
    - url: /.*
      script: MLP.app
    - url: /_ah/spi/.*
      script: MLP_mobile_backend.APPLICATION
    
    libraries:
    - name: webapp2
      version: latest
    - name: jinja2
      version: latest
    - name: pycrypto
      version: latest
    - name: endpoints
      version: 1.0
    

MLP.py is just web service with webapp2

How can I solve the problem?


Answer: From the `app.yaml` line `script: MLP_mobile_backend.APPLICATION`, it means
your code sample must live in a `MLP_mobile_backend.py` file at the root of
your app engine project

    
    
    .
    ├── app.yaml 
    ├── MLP.py 
    └── MLP_mobile_backend.py
    

with an endpoint api server named `APPLICATION` defined in that file just as
in your code sample above.

    
    
    APPLICATION = endpoints.api_server([HelloWorldApi])
    

After those requirements are fulfilled, this line points to how to access your
endpoints:

    
    
    @endpoints.api(name='helloworld', version='v1')
    

So for example, let's say you're running your devserver's module on port 8080
and you want to access the **hellogreeting** path:

    
    
    @endpoints.method(message_types.VoidMessage, GreetingCollection,
                      path='hellogreeting', http_method='GET',
                      name='greetings.listGreeting')
    

you can use [_cURL_](http://curl.haxx.se) or [_httpie_](http://httpie.org/) or
_your browser_ to locally navigate to the devserver's default module at
<http://localhost:8080/_ah/api/helloworld/v1/hellogreeting> or with Google's
API explorer at <http://localhost:8080/_ah/api/explorer> which should result
in this response body:

    
    
    {
     "items": [
      {
       "message": "hello world!"
      }, 
      {
       "message": "goodbye world!"
      }
     ]
    }
    

Once you get it set up locally, you can then deploy it.

[More
here](https://cloud.google.com/appengine/docs/python/endpoints/test_deploy)

