title: Insert a related object by ID, using endpoints-proto-datastore
body: <p>I'm trying to insert a Category object, but I like to link a Category to a Store using the Store ID. The ID is by endpoints-proto-datastore.  How Can I do that?</p>
  
  <p>Actually, to save a Category, the API require the Category name and the Store Key.</p>
  
  <p>This is my api method:</p>
  
  <pre><code>@Category.method(user_required=True, 
                  request_fields=('name'), 
                  path='{store}/categories', 
                  http_method='POST', 
                  name='categories.insert')
  def insertCategory(self, category):
      """
      Insert a category in a existing store.
      """
      category.put()
      return category
  </code></pre>
  
  <p>this is my Category model:</p>
  
  <pre><code>class Category(EndpointsModel):
      _message_fields_schema = ('id', 'name', 'store')
      name = ndb.StringProperty(required=True)
      store = ndb.KeyProperty(Store)
  </code></pre>
  
  <p>and this is my Store model:</p>
  
  <pre><code>class Store(EndpointsModel):
      _message_fields_schema = ('id', 'name')
       name = ndb.StringProperty(required=True)  
  </code></pre>