How do I save new object with relation to an existing one? (REST)

Let’s suppose i’m adding new contact to the phone book. I already have the table of cities.

How do i create new contact (row) in the phoneBook with relation to one of the existing cities from Cities table?

I’ve created the phoneBook table with the ‘cities’ column (relation one-to-one to cities). I’ve tried to save new object in phonebook, which has ‘sities’: ‘xxxx-xxxx-xxxx-xxxx’ (the objectId of the certain city). Seems it doesn’t work.

This can be done by referencing objectId of an existing city in the relation property. If you could show your REST request, it would make it easier for us to help you.

https://api.backendless.com/v1/data/Phonebook

post
headers= {

    'application-id': '...',
'secret-key': '...',
'Content-Type':'application/json',
'application-type': 'REST'
    'user-token: '...'

}

body = {
name: ‘string’,
phone: ‘string’,
city: ‘objectId of the existing city here’,
}

Change the value of “city” to this:

city: 
{ 
   objectId:"value of the object id property of existing city",
  ___class:"Cities"
}

Make sure the table is called “Cities” or just change the value for the ___class element.

Hi Mark,
I have same problem,
when is send this by POST:

{
“title”: “titleeeeee”,
“fullBody”:“sfaf”,
“summaryBody”: “dsfsd”,
“category”:{
“___class”:“ArticeCategory”,
“objectId”:“3B8F1B3E-0E08-7350-FF12-196D26E1A300” // this object is already exists
}
}

Category Class is also updated and all of it’s fields reseted.

@hadi, please see my response in the other topic you created.