Cannot post data to multiple tables with joins

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.

1 Like

@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
}
]
}

1 Like