Creating a Sublist
During create operations, lines of a keyed sublist are updated if the line contains matching keys, and the remaining lines from the request are added. For non-keyed sublists, the lines are always appended to the ones that are already present on the sublist by default. The following is an example of a POST operation upon a sublist.
Request Body
POST .../myrecord
{
"body1": "inserted body text 1",
"sublist" : {
"items" : [
{ "key1": "a", "key2": "1", "col": "inserted line 1" },
{ "key1": "b", "key2": "2", "col": "inserted line 2" }
]
},
"unkeyedsublist" : {
"items" : [
{ "col": "inserted line 1" },
{ "col": "inserted line 2" }
]
}
}
Response – Post State
Response:
201 Created
Location: .../myrecord/101
{
"body1": "inserted body text 1",
"body2": "default body text 2",
"sublist" : {
"items" : [
{ "key1": "a", "key2": "1", "col": "inserted line 1" },
{ "key1": "b", "key2": "2", "col": "inserted line 2" },
{ "key1": "X", "key2": "0", "col": "default line 0" },
]
},
"unkeyedsublist" : {
"items" : [
{ "col": "default line 1" },
{ "col": "default line 2" },
{ "col": "default line 0" },
{ "col": "inserted line 1" },
{ "col": "inserted line 2" },
]
}
}
Note:
Keyed sublist lines are updated if the key matches, otherwise, a new line is created (in other words, sublist lines are merged). Lines for non-keyed sublists are added.