Subscribe rss
Blog categories
All | Backendless features
Feature 121: Adding objects with relations using REST Console
May 10, 2015 by markpiller

Previously I described how to save data objects using REST Console. The same interface allows to save objects with related data – it is strictly a matter of formatting the request body. Consider the following two data table schemas:

Restaurant table schema:

Notice the locations  column, which represents a one-to-many relation with the Location table:

To save a new object in the Restaurant table using REST Console:

  1. Select the Restaurant table and click REST Console.
  2. Enter the following JSON object into the Request body field:

    Notice the locations element – it contains an array with one object. The reason for the array is the one-to-many relationship between Restaurant and Location tables.Additionally, the object inside of the “locations” array contains a special property ___class. The property indicates that the object is an “instance” of the Location object and should be placed into the Locations table.
  3. Click the POST button to save the objects. You will see a response similar to the one in the screenshot below:
Share this post
Tweet about this on TwitterShare on FacebookGoogle+