我有一个带有表单的应用程序,提交后将用相应的信息更新Microsoft团队。主要目标是删除和添加团队成员/所有者。
我正在为此创建批处理请求。
首先,我的批处理请求如下所示:
batch = [{
id: 1,
method: "POST",
url: "teams/" + {THE-teamID} + "/members",
headers: {
"Content-Type": "application/json",
},
body: {
"@odata.type": "#microsoft.graph.aadUserConversationMember",
roles: ["owner"],
"user@odata.bind": OWNERTOADD,
},
},
,{
id: 2,
method: "POST",
url: "teams/" + {THE-teamID} + "/members",
headers: {
"Content-Type": "application/json",
},
body: {
"@odata.type": "#microsoft.graph.aadUserConversationMember",
roles: ["member"],
"user@odata.bind": MEMBERTOADD,
},
}
,{
id: 2,
method: "POST",
url: "teams/" + {THE-teamID} + "/members",
headers: {
"Content-Type": "application/json",
},
body: {
"@odata.type": "#microsoft.graph.aadUserConversationMember",
roles: ["member"],
"user@odata.bind": MEMBERTOADD,
},
}
,{
id: 3,
method: "DELETE",
url: "groups/" + {THE-teamID} + "/members/"+{member-id}+"/$ref",
headers: {
"Content-Type": "application/json",
},
}
,{
id: 4,
method: "DELETE",
url: "groups/" + {THE-teamID} + "/owners/"+{owner-id}+"/$ref",
headers: {
"Content-Type": "application/json",
},
}]
使用此批处理呼叫时,我收到一个错误,即团队必须至少拥有一个所有者。我理解此错误,因为我的批处理没有任何depenOn属性,因此不保证单个调用将按“正确”的顺序执行。
我的问题是,当我添加行时
dependsOn: [ '1' ],
到我的上一个批处理请求,我在整个批处理调用中仅收到400 Bad Request错误,没有任何其他信息。我还尝试过所有其他呼叫都依赖于我的add-new-owner-call,但没有成功。有人知道我哪里出问题了吗?还是我正在尝试做的事情是可能的?
编辑1:我做了一个变通办法,将添加和删除调用划分为两个单独的批处理调用。它并不完美,但至少可以正常工作。