Skip to content Skip to sidebar Skip to footer

How Do You Return A Partial Response In App Engine Python Endpoints?

I am learning endpoints and saw that other Google APIs have this 'fields' query attribute. Also it appears in the api explorer. I would like to get a partial response for my api

Solution 1:

From what I gather, Google has enabled partial response for their APIs, but has not yet explained how to enable it for custom APIs. I'm assuming if they do let us know, it might entail annotations, and possibly overriding a method or two.

I've been looking also, to no avail. I've been looking into this just due to a related question, where I'd like to know how to force the JSON object in the response from my google Endpoint API, to include even the members of the class that are null valued. I was trying to see if anything would be returned if I used a partial response with a field indicated that was null.. would the response have the property at least, or would it still not even exist as a property.

Anyway, this lead me into the same research, and I do not believe we can enable partial responses in our own APIs yet.

Solution 2:

You can return a partial response by defining the parameter in @MyModel.method

@MyModel.method(path='mymodel',
                  http_method='POST',
                  name='mymodel.insert',
                  response_fields=('model_id', 'date_time'))defmymodel_insert(self, mymodel):
    mymodel.put()
    return mymodel

Check out this tutorial Endpoints tutorial

Post a Comment for "How Do You Return A Partial Response In App Engine Python Endpoints?"