How to call post api while connecting one to one relationship between two tables?

I have two tables with one to one relationship as following

I need to call the api to create the record as following

api end-point : http://localhost:81/api/v2/treat_well/_table/tw_venue?related=tw_venue_contact

body:

{
  "resource": [
    {
      "name": "Rest Point",
      "type_id" : "1",
      "description":"The comfort place to take rest with our care.",
      "logo":"http://www.logo.png",
      "tw_venue_contact_by_venue_id":[
        {
              "longtitude":"6.87491200",
              "latitude" : "6.87491200",
              "address" : "Colombo-06",
              "city_id" : "1",
              "country_id" : "1",
              "phone" : "0112345678",
              "mobile" : "0771234567",
              "email" : "touch@relif.com",
              "website" : "http://relief.com",
              "twitter" : "http://google.com/releif",
              "google" : "http://google.com/releif",
              "added_date" : "2016-01-01",
              "user_id" : "26"

        }
        ]
      
    }
  ]
}

Iā€™m getting error as following

{
ā€œerrorā€: {
ā€œcontextā€: null,
ā€œmessageā€: ā€œFailed to update many to one assignment.\nRelated record has no primary key value for ā€˜venue_idā€™.ā€,
ā€œcodeā€: 400,

Iā€™m trying to create the records by with having** one to one relationship** why do i get this error from DSP?

But when i try to create the records between one to many relationship tables itā€™s working fine.

Whatā€™s the mistake that i have been here? Please anyone explain to me @formerstaff @benbusse ā€¦

1 Like