【发布时间】:2013-12-29 04:08:27
【问题描述】:
我在端点原型数据存储区尝试了几天的简单获取。
http://endpoints-proto-datastore.appspot.com/examples/simple_get.html
它可以工作,但它总是返回 not found。
这是通过 id 获取的 api。
https://pttbuying.appspot.com/_ah/api/pttbuying/v1/items/4504690549063680
这是我的型号代码。
class Item(EndpointsModel):
_message_fields_schema = ('id', 'item_title', 'item_link', 'item_price', 'item_description_strip', 'datetime')
item_title = ndb.StringProperty(indexed=False)
item_author_name = ndb.StringProperty(indexed=False)
item_link = ndb.StringProperty(indexed=True)
item_description_strip = ndb.StringProperty(indexed=False)
item_price = ndb.StringProperty(indexed=False)
datetime = ndb.DateTimeProperty(auto_now_add=True)
这是我的 api 代码
@endpoints.api(name='pttbuying', version='v1',
allowed_client_ids=[WEB_CLIENT_ID, ANDROID_CLIENT_ID,
IOS_CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID],
audiences=[ANDROID_AUDIENCE],
scopes=[endpoints.EMAIL_SCOPE])
class PttBuyingApi(remote.Service):
"""PttBuying API v1."""
@Item.method(request_fields=('id',),
path='items/{id}', http_method='GET', name='item.MyModelGet')
def MyModelGet(self, my_item):
if not my_item.from_datastore:
raise endpoints.NotFoundException('Item not found.')
return my_item
@Item.query_method(query_fields=('limit', 'order', 'pageToken'), path='items', name='item.list')
def MyModelList(self, query):
return query
我错过了什么吗? 感谢您的建议。
【问题讨论】:
标签: google-app-engine python-2.7 google-cloud-datastore google-cloud-endpoints endpoints-proto-datastore