0

Google App Engine用のアプリがあります。バックエンドはPythonを使用し、フロントエンドはJavaScriptを使用します。このアプリケーションはローカルで正常に動作し、API Explorerはデプロイ時に正常に動作します。Google Cloud Endpoints:エンドポイントリクエストパラメータ(リソースコンテナ)デプロイ時に空白

ただし、展開時にAPIがフロントエンドで正常に機能しません。問題は、要求から引数(「リソースコンテナ」)を受け取るクラウドエンドポイントメソッドが「空の」リクエストを受け取ることです.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)); 
    } 
}); 

クラウドエンドポイント:展開したときuser_google_idリクエストで行きました

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() 

?なぜPythonはそこに何もないと思うのですか?

答えて

0

私はそれを働かせました。主な修正はthis documentationに基づいていました。私は "要求本体に渡すすべての引数を持つメッセージクラスを定義"し、そのクラスを含むように要求メッセージで使用されるリソースコンテナを定義しました。

関連する問題