# Cannot post data to multiple tables with joins

**URL:** <https://community.dreamfactory.com/t/cannot-post-data-to-multiple-tables-with-joins/2728>\
**Category:** Schema & Data\
**Created:** [May 19, 2016, 5:01am UTC](https://community.dreamfactory.com/t/cannot-post-data-to-multiple-tables-with-joins/2728 "2016-05-19T05:01:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manvir\_Singh](https://avatars.discourse-cdn.com/v4/letter/m/c0e974/32.png) [@Manvir\_Singh](https://community.dreamfactory.com/u/Manvir_Singh)\
**Post date:** [May 19, 2016, 5:01am UTC](https://community.dreamfactory.com/t/cannot-post-data-to-multiple-tables-with-joins/2728/1 "2016-05-19T05:01:37Z")

</div>

Hi I cannot seem to get Dreamfactory to post to a multiple table which are all related. im am facing the error as per below.

`
{
  "error": {
    "context": null,
    "message": "Failed to update belongs-to assignment.\nRequired field 'serialnumber' can not be NULL.",
    "code": 400
  }
}
`

How ever the variables are not NULL and have been provided in the JSON

`
{
“resource”: [
{
“intNo”: “999”,
“name”: “Test Optic”,
“lat”: “1”,
“log”: “1”,
“state”: “1”,
“lightCharacteristic”: “asd”,
“flashTime”: “123”,
“lightRange”: “123”,
“effcetiveIntensity”: “123”,
“elevation”: “123”,
“structureHeight”: “1”,
“description”: “1”,
“established”: “2016-05-10”,
“emergencyLightRange”: “123”,
“emergencyLightIntensity”: “123”,
“SCADA”: “SCADA”,
“AIS”: “AIS”,
“racon”: “Racon”,
“inventory_by_optic”: [
{
“type”: 2,
“serialNumber”: “123”,
“purchaseDate”: “2016-01-01”,
“status”: 1,
“name”: “Test Inventory Optic”,
“brand”: “Osram”,
“rating”: “This is Rating”,
“custom1”: “”,
“custom2”: “”,
“custom3”: “”,
“custom4”: “”,
“custom5”: “”,
“custom6”: “”
}
],
“battery”: “1”,
“lamp”: “1”,
“powerSupply”: “1”,
“emergencyLamp”: “1”,
“inspectionDate”: “2016-05-10”,
“gallery”: “1”,
“status”: 4
}
]
}
`

This is the relation in the schema ;

`
"related": [
    {
      "alias": null,
      "name": "inventory_by_optic",
      "label": "Inventory By Optic",
      "description": null,
      "always_fetch": false,
      "flatten": false,
      "flatten_drop_prefix": false,
      "type": "belongs_to",
      "field": "optic",
      "is_virtual": false,
      "is_foreign_service": false,
      "ref_service": null,
      "ref_service_id": null,
      "ref_table": "inventory",
      "ref_fields": "inventoryID",
      "ref_on_update": null,
      "ref_on_delete": null,
      "is_foreign_junction_service": false,
      "junction_service": null,
      "junction_service_id": null,
      "junction_table": null,
      "junction_field": null,
      "junction_ref_field": null
    }
`

I have no idea where to start with this.

---

<div class="post-metadata">

**Author:** ![mattschaer](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/mattschaer/32/914_2.png) [@mattschaer](https://community.dreamfactory.com/u/mattschaer)\
**Post date:** [July 6, 2016, 5:21pm UTC](https://community.dreamfactory.com/t/cannot-post-data-to-multiple-tables-with-joins/2728/2 "2016-07-06T17:21:16Z")

</div>

@Manvir_Singh what is the data type expected for the ‘serial number’ field? Can you try the POST again removing the double quotes as follows and tell me if anything changes?:

{  
“resource”: [  
{  
“intNo”: “999”,  
“name”: “Test Optic”,  
“lat”: “1”,  
“log”: “1”,  
“state”: “1”,  
“lightCharacteristic”: “asd”,  
“flashTime”: “123”,  
“lightRange”: “123”,  
“effcetiveIntensity”: “123”,  
“elevation”: “123”,  
“structureHeight”: “1”,  
“description”: “1”,  
“established”: “2016-05-10”,  
“emergencyLightRange”: “123”,  
“emergencyLightIntensity”: “123”,  
“SCADA”: “SCADA”,  
“AIS”: “AIS”,  
“racon”: “Racon”,  
“inventory\_by\_optic”: [  
{  
“type”: 2,  
“serialNumber”: 123,  
“purchaseDate”: “2016-01-01”,  
“status”: 1,  
“name”: “Test Inventory Optic”,  
“brand”: “Osram”,  
“rating”: “This is Rating”,  
“custom1”: “”,  
“custom2”: “”,  
“custom3”: “”,  
“custom4”: “”,  
“custom5”: “”,  
“custom6”: “”  
}  
],  
“battery”: “1”,  
“lamp”: “1”,  
“powerSupply”: “1”,  
“emergencyLamp”: “1”,  
“inspectionDate”: “2016-05-10”,  
“gallery”: “1”,  
“status”: 4  
}  
]  
}
