1

過去数日間、Google Cloud Endpoints をいじっていました (AngularJS に接続することを目指しています)。データストアから単一のエンティティを取得しようとすると、少し問題が発生しました。

私のndbモデル設定は次のとおりです。

class Ingredients(EndpointsModel):
    ingredient = ndb.StringProperty()

class Recipe(EndpointsModel):
    title = ndb.StringProperty(required=True)
    description = ndb.StringProperty(required=True)
    ingredients = ndb.StructuredProperty(Ingredients, repeated=True)
    instructions = ndb.StringProperty(required=True)

エンティティを取得するために定義した API メソッドは次の'title'とおりです。

    @Recipe.method(request_fields=('title',), path='recipe/{title}',
                   http_method='GET', name='recipe.get')
    def get_recipe(self, recipe):
        if not recipe.from_datastore:
            raise endpoints.NotFoundException('Recipe not found.')
        return recipe   

リクエスト フィールドの代わりに'id'(によって提供されるヘルパー メソッド)を使用する場合、API メソッドは正常に機能します。ただし、を使用すると、EndpointsModel'title''title'

404お探しのページが見つかりませんでした

{"error_message": "レシピが見つかりません。","state": "APPLICATION_ERROR"}

どこかで何かが欠けている場合、誰かが指摘できますか?

: コメントを参照してください。読んでいた質問の誤り

400不正な要求

{"error_message": "ProtoRPC リクエストの解析中にエラーが発生しました (リクエストの内容を解析できません: メッセージ RecipeProto_title に必須フィールドのタイトルがありません)", "state": "REQUEST_ERROR"}

しかし、@sentikiはこの以前のエラーを解決できました。

4

1 に答える 1