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


#1

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 @drewpearce @benbusse