Using POSTMAN to POST object with relation to another table using REST API

I’m trying to add a new object to a table where some columns (instructors and class names) have a relation with other tables.

I’m facing some issues with adding a new object that sets the relation (eg. I want to add a schedule item that sets instructor A as the “instructor”, and class name A as the “class name”).

Here’s my JSON body:

{
    "classStart": 1601298000000,
    "zoomPW": "340073",
    "classEnd": 1601301600000,
    "created": 1599137953000,
    "active": true,
    "capacity": 20,
    "zoomID": "865 7719 5468",
    "classDuration": 60,
    "zoomLink": "https://us02web.zoom.us/j/86577195468?pwd=R0Y1QW1RMitET2xieUJLb3FSV3c1dz09",
    "className":
  [
    {
      "___class":"classTypes",
      "name":"Ashtanga Basics (Livestream)"
    }
  ],
  "instructor":
  [
    {
      "___class":"instructors",
      "name":"James"
    }
  ]
}

Based on Backendless’s documentation and tutorials, it seems like the code above is correct, but somehow, the object created has its instructor and class name fields empty.

So I managed to create an object in the table, but the relation fields return empty.

I’ve followed the tutorial here https://backendless.com/how-to-add-objects-with-relations-using-rest-console/ but doesn’t seem to work for me.

Am I missing something?

Thank you so much in advance :slight_smile:

Hello @Peculiar_Yogi

We apologize for any misunderstanding. The feature described in the article above will appear in the next releases. For now, you can only use the ADD / SET Relation methods:

https://backendless.com/docs/rest/data_explicit_relation_list.html

Regards,
Inna

Hey @Inna_Shkolnaya, so just to clarify: we have to create the object first in the first API call, and in a separate API call, to add/set the relations, yes?

@Peculiar_Yogi

Yes, you are absolutely right.

Regards

Alright, thanks for clarifying!

Hi @Peculiar_Yogi, @Inna_Shkolnaya did the solution work for you.

Even after following this, I could not solve the relationship. I am following this link:

Set/Add Relation with objects - Backendless REST API Documentation.

Although the REST API seems to have executed with Success response, but I do not see the relation getting created in Reviews table.

I intended to update the relationship “RestaurantLinked” (1:1 between Reviews and Restaurant tables) for the following record in Reviews Table.

But even after successful execution of the REST API, the relation remains empty! What am I really missing ?

Many thanks in advance :slight_smile:

I have found the mistake, I was using wrong verb, should have used “PUT” and not “GET”.

Thanks!