You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SharePoint Online REST API $batch请求返回400 Invalid Request错误排查

SharePoint Online 批量删除400错误解决方案

核心错误点

1. 子请求使用了绝对URL

SharePoint Online /_api/$batch 接口要求所有批量内的子请求必须使用站点相对路径,不支持传入带域名的完整绝对URL。
你当前的错误写法:

DELETE https://myOrg.sharepoint.com/sites/mySite/_api/web/lists/getByTitle(myList)/items(27) HTTP/1.1

2. getByTitle参数缺少字符串标识

getByTitle 方法接收字符串类型的列表名,必须用单引号包裹参数值,未加引号的myList会被解析为未知变量,触发请求格式错误。

修正方案

将批量内的DELETE请求替换为相对路径、补充参数引号即可,可选补充Host头适配严格校验场景:

DELETE /sites/mySite/_api/web/lists/getByTitle('myList')/items(27) HTTP/1.1
Host: myOrg.sharepoint.com
If-Match: *

完整修正后的请求示例

POST /_api/$batch HTTP/1.1
Accept: application/json; odata=nometadata
Content-Type: multipart/mixed; boundary="batch_8215457c-c4fb-432a-abf6-7b1f86168c65"
Authorization: Bearer <token deleted>

--batch_8215457c-c4fb-432a-abf6-7b1f86168c65
Content-Type: multipart/mixed; boundary="changeset_d9097ba9-2d69-40ca-a301-90cf97aafb17"
Content-Transfer-Encoding: binary

--changeset_d9097ba9-2d69-40ca-a301-90cf97aafb17
Content-Type: application/http
Content-Transfer-Encoding: binary

DELETE /sites/mySite/_api/web/lists/getByTitle('myList')/items(27) HTTP/1.1
Host: myOrg.sharepoint.com
If-Match: *

--changeset_d9097ba9-2d69-40ca-a301-90cf97aafb17
Content-Type: application/http
Content-Transfer-Encoding: binary

DELETE /sites/mySite/_api/web/lists/getByTitle('myList')/items(30) HTTP/1.1
Host: myOrg.sharepoint.com
If-Match: *

--changeset_d9097ba9-2d69-40ca-a301-90cf97aafb17--

--batch_8215457c-c4fb-432a-abf6-7b1f86168c65--

内容的提问来源于stack exchange,提问作者RobK

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 10:45:08