I'm working with Google Endpoints with the basic example of endpoints-proto-datastore in http://endpoints-proto-datastore.appspot.com/
This is my file widgettiny_api.py
import endpoints
from google.appengine.ext import ndb
from protorpc import remote
from endpoints_proto_datastore.ndb import EndpointsModel
class Noticia(EndpointsModel):
_message_fields_schema = ('id', 'titulo', 'contenido', 'creado')
titulo = ndb.StringProperty()
contenido = ndb.StringProperty()
url_imagen = ndb.StringProperty()
url = ndb.StringProperty()
creado = ndb.DateTimeProperty(auto_now_add=True)
@endpoints.api(
name='WidgetTinyApi',
version='v1',
description='API usada para consumir las noticias desde el cliente android o widget.')
class WidgetTinyApi(remote.Service):
@Noticia.method(
path="noticia",
http_method="POST",
name="noticia.insert")
def NoticiaInsert(self, my_model):
my_model.put()
return my_model
@Noticia.method(
request_fields=('id',),
path='noticia/{id}',
http_method='GET',
name='noticia.get')
def NoticiaGet(self, my_model):
if not my_model.from_datastore:
raise endpoints.NotFoundException('Noticia no encontrada')
return my_model
@Noticia.query_method(
path="noticias",
name="noticia.list")
def NoticiaList(self, query):
return query
APPLICATION = endpoints.api_server([WidgetTinyApi], restricted=False)
I open link /_ah/api/explorer . I get this errors:
INFO 2013-11-22 16:24:28,992 module.py:608] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 200 2957
ERROR 2013-11-22 16:24:29,354 discovery_api_proxy.py:55] Discovery API proxy failed on /_ah/api/discovery/v1/apis/generate/directory with 400.
Request: {"configs": ["{\"description\": \"API usada para consumir las noticias desde el cliente android o widget.\", \"abstract\": false, \"name\": \"WidgetTinyApi\", \"descriptor\": {\"methods\": {\"WidgetTinyApi.NoticiaList\": {\"response\": {\"$ref\": \"NoticiaCollection\"}}, \"WidgetTinyApi.NoticiaInsert\": {\"request\": {\"$ref\": \"Noticia\"}, \"response\": {\"$ref\": \"Noticia\"}}}, \"schemas\": {\"NoticiaCollection\": {\"type\": \"object\", \"id\": \"NoticiaCollection\", \"properties\": {\"nextPageToken\": {\"type\": \"string\"}, \"items\": {\"items\": {\"$ref\": \"Noticia\"}, \"type\": \"array\"}}}, \"Noticia\": {\"type\": \"object\", \"id\": \"Noticia\", \"properties\": {\"contenido\": {\"type\": \"string\"}, \"titulo\": {\"type\": \"string\"}, \"url_imagen\": {\"type\": \"string\"}, \"url\": {\"type\": \"string\"}, \"created\": {\"type\": \"string\"}}}}}, \"version\": \"v1\", \"extends\": \"thirdParty.api\", \"defaultVersion\": true, \"root\": \"http://localhost:20999/_ah/api\", \"adapter\": {\"bns\": \"http://localhost:20999/_ah/spi\", \"type\": \"lily\", \"deadline\": 10.0}, \"methods\": {\"widgetTinyApi.noticia.insert\": {\"scopes\": [\"https://www.googleapis.com/auth/userinfo.email\"], \"clientIds\": [\"292824132082.apps.googleusercontent.com\"], \"rosyMethod\": \"WidgetTinyApi.NoticiaInsert\", \"request\": {\"body\": \"autoTemplate(backendRequest)\", \"bodyName\": \"resource\"}, \"authLevel\": \"NONE\", \"httpMethod\": \"POST\", \"path\": \"noticia\", \"response\": {\"body\": \"autoTemplate(backendResponse)\", \"bodyName\": \"resource\"}}, \"widgetTinyApi.noticia.list\": {\"scopes\": [\"https://www.googleapis.com/auth/userinfo.email\"], \"clientIds\": [\"292824132082.apps.googleusercontent.com\"], \"rosyMethod\": \"WidgetTinyApi.NoticiaList\", \"request\": {\"body\": \"empty\"}, \"authLevel\": \"NONE\", \"httpMethod\": \"GET\", \"path\": \"noticias\", \"response\": {\"body\": \"autoTemplate(backendResponse)\", \"bodyName\": \"resource\"}}}}"]}
Response: {
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
ERROR 2013-11-22 16:24:29,355 discovery_service.py:137] Failed to get API directory
INFO 2013-11-22 16:24:29,355 module.py:608] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 404 9
What is the error?
name='WidgetTinyApi'
is invalid. You need a lowercase value for this.
From the documentation:
The name value:
- Must begin with lowercase.
- Must match the regular expression
[a-z]+[A-Za-z0-9]*
.