要更新实体,我使用 http PUT,将更新的对象作为请求正文传递:
PUT /api/flareform/3
{
"JobId" : "12-12-4004",
"Id" : 3,
"Tasks" : [
{
"Hazard" : "Clumsyness",
"Id" : 2,
"FlareFormId" : 3,
"Task" : "Hammering",
"Control" : "Make Someone Else Hold the Nail"
},
{
"Hazard" : "Nails",
"Id" : 3,
"FlareFormId" : 3,
"Task" : "Walking",
"Control" : "Keep area clean."
}
],
"PercentComplete" : null,
"Time" : "3pm",
"Initials" : "JD"
}
如果我更新对象的简单属性(例如 Initials),这将正常工作。是否有可能/如何更新、添加、删除任务。可以通过这个对象吗?我想做的只是传递一个更新的任务数组并让它更新/删除/添加所有内容:
PUT /api/flareform/3
{
"JobId" : "12-12-4004",
"Id" : 3,
"Tasks" : [
{
"Hazard" : "NewAndImprovedValue",
"Id" : 2,
"FlareFormId" : 3,
"Task" : "NewAndImprovedValue",
"Control" : "NewAndImprovedValue"
},
{
"Hazard" : "SomeNewItemThatDidntExistBefore",
"FlareFormId" : 3,
"Task" : "NoteTheMissingId",
"Control" : "ShouldAddThisOne"
}
],
"PercentComplete" : null,
"Time" : "3pm",
"Initials" : "JD"
}