我有一個模型如何通過entityKey和endpoints-proto-datastore檢索對象?
class MyModel(EndpointsModel):
_message_fields_schema = ('entityKey', 'prop')
prop = ndb.StringProperty()
和API方法:
@MyModel.method(request_fields=('entityKey',),
path='mymodel/{entityKey}', http_method='GET', name='mymodel.get')
def mymodel_get(self, mymodel):
if not mymodel.from_datastore:
raise endpoints.NotFoundException('mymodel not found.')
return mymodel
但是,當我嘗試像
http://localhost:8080/_ah/api/myapi/v1/mymodel/adsfasf-cm9jay1zdG9wchELEgRBcmVhGICAgICAgIAJDA
查詢,我收到了404我知道對象存在,我知道這是正確的urlsafe鍵。這是怎麼回事?使用'id'而不是'entityKey'並使用整數鍵查詢時,相同的代碼有效。