google cloud endpoints - Error when trying to retrieve a single entity -


i've been playing around google cloud endpoints past few days (aiming hook angularjs) , ran bit of trouble when try retrieve single entity datastore.

my ndb model setup is:

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) 

here api method i've defined retrieve entity '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    

the api method works fine if use 'id' (helper methods provided endpointsmodel) in place of 'title' request fields. when use 'title', however, i'm getting

404 not found

{"error_message": "recipe not found.","state": "application_error"}

can point out if missing somewhere?

note: see comments. error in question used read

400 bad request

{"error_message": "error parsing protorpc request (unable parse request content: message recipeproto_title missing required field title)", "state": "request_error"}

but @sentiki able resolve previous error.

the 404 expected. "magic" of id property calls updatefromkey.

this method tries set ndb.key on entity based on request , attempts retrieve entity stored key. if entity exists, values datastore copied on entity parsed request , _from_datastore property set true.

by using request_fields=('title',), have simple data property rather endpointsaliasproperty , values set. result, _from_datastore never gets set , check

    if not recipe.from_datastore:         raise endpoints.notfoundexception('recipe not found.') 

throws endpoints.notfoundexception expected.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -