Error 1007 when saving nested relations

I am using the REST interface.

I have 3 tables with 1:n relations: C->B->A
Consider an instance of C which has two Bs. One B has an A, the other B has no As.
When POSTing or PUTting such a resource via the REST API, it fails with
{
“code”: 1007,
“message”: “Unable to save object - invalid data type for properties - rel. You can change the property type in developer console.”
}Rel is the property of B holding the list of As, apparently the empty list [] cannot be typed correctly.Below is a resource which I retrieved via GET after entering data and setting up the relations through the development console. PUTting back the exact same value fails with error 1007. {
“b”: [
{
“created”: 1455487724000,
“rel”: [],
“___class”: “B”,
“ownerId”: null,
“updated”: 1455523210000,
“objectId”: “212E05CE-0609-9F5E-FF88-08548298DA00”
},
{
“created”: 1455487648000,
“rel”: [
{
“a”: “x”,
“created”: 1455487629000,
“___class”: “A”,
“ownerId”: null,
“updated”: null,
“objectId”: “E8DD8545-2C1F-18A8-FF0B-859CB7FBD000”
}
],
“___class”: “B”,
“ownerId”: null,
“updated”: null,
“objectId”: “5F7FB7D7-7C67-A726-FF43-FD01633CA100”
}
],
“created”: 1455487740000,
“___class”: “C”,
“ownerId”: null,
“updated”: 1455523210000,
“objectId”: “BAC09293-66EA-A9A7-FF7D-9B9BCBBF4500”,
“__meta”: “{“relationRemovalIds”:{},“selectedProperties”:[”__updated__meta",“b”,“created”,"___class",“ownerId”,“updated”,“objectId”],“relatedObjects”:{“b”:[“212E05CE-0609-9F5E-FF88-08548298DA00”,“5F7FB7D7-7C67-A726-FF43-FD01633CA100”]}}"
}

Hi Tore,

Try putting null when there is no relation or completely omitting the “rel” property.

Regards,
Mark

Sending null seems to work.

Omitting the property means it does not get updated so if the B ha relations before they are not removed by the PUT.

I’ll go with null for now but I would still consider this a bug: It’s inconsistent that the API does not accept the same representation it delivers from GET, and in a real application it’s pretty inconvenient to search through the data structure to replace empty arrays with null before marshalling to JSON.

What if relationship is there, but the client explicitly requests NOT to load it? Should it be null or empty array? How does the client know if the data is really there? This is a gray area and the argument can be made either way.