Google Cloud Endpoints:端点请求参数(资源容器)在部署时为空

Google Cloud Endpoints: Endpoint Request Parameters (Resource Containers) Empty when Deployed

我有一个适用于 Google App Engine 的应用程序。后端使用Python,前端使用JavaScript。该应用程序在本地按预期工作,API Explorer 在部署后按预期工作。

但是,API 在部署时无法像预期的那样与前端一起工作。问题是从请求中获取参数 ("Resource Containers") 的云端点方法收到 "empty" 请求——从 JavaScript 前端提供给请求的参数消失了。

这是一个例子。

JavaScript API 来电:

var id_resource = {'resource': {'user_google_id': "-1"}};

gapi.client.word_match.get_user_from_google_id(id_resource).execute(function(resp) {

    console.log(resp); // THE API CALL 'LOSES' THE 'user_google_id' WHEN DEPLOYED: THIS LOGS AN ERROR ("Object {code: 404, data: Array[1], message: "No user with the id "None" exists.", error: Object}") WHEN DEPLOYED, BUT LOGS THE CORRECT USER INFO LOCALLY
    if (!resp.code) {

        self.user(new User(resp));
    }
});

云端点:

REQUEST_BY_GOOGLE_ID = endpoints.ResourceContainer(user_google_id=messages.StringField(1),)

@endpoints.api(name='word_match', version='v1', allowed_client_ids=['the id'],
    auth_level=endpoints.AUTH_LEVEL.OPTIONAL_CONTINUE)
class WordMatchApi(remote.Service):
    """Game API
    """
    @endpoints.method(request_message=REQUEST_BY_GOOGLE_ID,
                      response_message=UserForm,
                      path='getuser',
                      name='get_user_from_google_id',
                      http_method='POST')
    def get_user_from_google_id(self, request):
        """Get a user by the user's google account ID
        """

        logging.info(request) // THIS IS THE ISSUE: LOGS "<CombinedContainer> user_google_id: u'-1'>" locally, but just "<CombinedContainer>" when deployed.
        logging.info(request.user_google_id)

        user = User.query(User.google_id == request.user_google_id).get()

        if not user:
            message = 'No user with the id "%s" exists.' % request.user_google_id
            raise endpoints.NotFoundException(message)

        return user.to_form()

部署时 user_google_id 在请求中去了哪里?为什么Python觉得那里什么都没有?

我成功了。主要修复基于 this documentation。我 "defined a message class that has all the arguments that will be passed in the request body",然后定义了请求消息中使用的资源容器以包含 class。