我在使用 _api/$batch 请求隔离批处理请求时遇到了一些麻烦。我确定只是发生了一些简单的错误/问题,但我不能只指出这一点。有任何想法吗?
以下是请求的原始邮递员控制台日志的一些片段:
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 https://myOrg.sharepoint.com/sites/mySite/_api/web/lists/getByTitle(myList)/items(27) HTTP/1.1
If-Match: *
Accept: application/json; odata=nometadata
--changeset_d9097ba9-2d69-40ca-a301-90cf97aafb17
Content-Type: application/http
Content-Transfer-Encoding: binary
DELETE https://myOrg.sharepoint.com/sites/mySite/_api/web/lists/getByTitle(myList)/items(30) HTTP/1.1
If-Match: *
Accept: application/json; odata=nometadata
--changeset_d9097ba9-2d69-40ca-a301-90cf97aafb17--
--batch_8215457c-c4fb-432a-abf6-7b1f86168c65--
我为每个要删除的项目返回的响应是 400 Bad Request,每个批处理响应还包含:{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message" :{"lang":"en-US","value":"无效请求。"}}}
--batchresponse_38add954-a201-4857-a6db-68067eb9bc0a
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 400 Bad Request
CONTENT-TYPE: application/json;odata=nometadata;streaming=true;charset=utf-8
{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Invalid request."}}}
--batchresponse_38add954-a201-4857-a6db-68067eb9bc0a
Content-Type: application/http
Content-Transfer-Encoding: binary
HTTP/1.1 400 Bad Request
CONTENT-TYPE: application/json;odata=nometadata;streaming=true;charset=utf-8
{"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"Invalid request."}}}
--batchresponse_38add954-a201-4857-a6db-68067eb9bc0a--
我一直在挖掘并尝试了一些事情:
- 尝试从每个变更集中删除“Accept: application/json; odata=nometadata”
- 在请求内容类型/编码后尝试调整任何换行符
- 我尝试将批处理中的一项作为单个删除请求执行(有效)
- 比较了一些笔记/示例:(Andrew Connell 博客:https ://gist.github.com/andrewconnell/dcd89e694475b628d0c7 )
有帮助的眼睛能指出错误吗?