My issue is rather simple, but due to my inexperience I am not sure how to accomplish what I want to do.
The backend that I am utilizing is Google App Engine, but I believe this is a general python question.
How can I structure my JSON response to return the exact object JSON back that was initially sent in the request?
class UserCreateRequestMessage(messages.Message):
email = messages.StringField(1, required=True)
password = messages.StringField(2, required=True)
class UserCreateResponseMessage(messages.Message):
email = messages.StringField(1)
username = messages.StringField(2)
# id = messages.IntegerField(3)
HERE IS THE API, THE PROBLEM IS WITH THE RETURN LINE
@endpoints.api(name='photoswap', version='v1')
class PhotoswapAPI(remote.Service):
@endpoints.method(UserCreateRequestMessage, UserCreateResponseMessage,
path='user', http_method='POST',
name='user.create')
def user_create(self, request):
entity = User(email=request.email, password=request.password)
entity.put()
return UserCreateResponseMessage(email=entity.email, password=entity.password)