Backendless Support

Adding objects with relations using REST Console

The same interface as shown in the topic "Creating / saving new data objects using REST Console" allows to to save objects with related data - it is strictly a matter of formatting the request body. 

Consider the following two data table schemes:

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:
 "name":"Mama Mia Pizzeria",
 "streetAddress":"123 Main St",
 "city":"New York"

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.

4.       Click the POST button to save the objects. You will see a response similar to the one in the screenshot below: 

Is article helpful?