Powershell:使用REST API从Sharepoint列表中删除项目-远程服务器返回错误:(400)请求错误

Powershell:使用REST API从Sharepoint列表中删除项目-远程服务器返回错误:(400)请求错误,powershell,sharepoint,Powershell,Sharepoint,我的问题是在Sharepoint 2013年至2019年迁移之后。我们的剧本 从列表中删除项目的操作已停止。我可以得到你的身份证 列表中的所有项目都很好,但第一次删除时返回400 错误。我注意到REST API URL已经更改,我做了这些更改,但是 不知道我错过了什么。下面是代码片段 输出 我相信你的帖子uri格式不正确。它看起来有点奇怪,项和Guid没有分离 POST http://sites.example.com/teams/Cloud_Enablement_Program/_api/we

我的问题是在Sharepoint 2013年至2019年迁移之后。我们的剧本 从列表中删除项目的操作已停止。我可以得到你的身份证 列表中的所有项目都很好,但第一次删除时返回400 错误。我注意到REST API URL已经更改,我做了这些更改,但是 不知道我错过了什么。下面是代码片段

输出


我相信你的帖子uri格式不正确。它看起来有点奇怪,
项和
Guid
没有分离

POST http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle('AWS Idaptive Accounts')/items5b0ec0be-7238-45ef-b7db-032accbb2677
看起来它需要
($ItemId)


https://{site\u url}/\u-api/web/lists/getbytitle('Documents')/items({item\u-id})

使用相同的结果进行更改。尝试在其周围添加单引号怎么样
(“+$ItemId+”)
@esmith.dev代码更改:
$Uri=$SharePointSite+/\u-api/web/lists/getbytitle(“+$ListName+”)/items+$id+”)
新输出:
http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/…IDAITIVE Accounts')/items(a014a632-3712-4257-a3e1-8703adfbcb83)具有0字节负载错误:无法删除SharePoint列表项[a014a632-3712-4257-a3e1-8703adfbcb83]:远程服务器返回错误:(400)错误请求
Hey@JP2尝试格式化它,以便请求包含guid周围的单引号。i、 e.
/items('a014a632-3712-4257-a3e1-8703adfbcb83')
@esmith.dev实现了这一点<代码>详细:发布http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle具有0字节负载的('AWS IDative Accounts')/items('da6c0d14-5590-4427-8830-ee955b6b83ef')相同错误:
错误:无法删除SharePoint列表项[da6c0d14-5590-4427-8830-ee955b6b83ef]:远程服务器返回错误:(400)请求错误。
* Initializing Headers ...
VERBOSE: Executing Function: Get-IdaptiveAuthToken
VERBOSE: Executing Command: $RequestDigest = Invoke-RestMethod -Uri http://sites.example.com/teams/Cloud_Enablement_Program/_api/contextinfo -Method POST  -UseDefaultCredentials
VERBOSE: POST http://sites.example.com/teams/Cloud_Enablement_Program/_api/contextinfo with 0-byte payload
VERBOSE: received -1-byte response of content type application/xml;charset=utf-8
VERBOSE: RequestDigest: 0x28A751C086DD8EFBE5EB6BF211B461D628EAE2756282F209186DC17930381B736B43E791E5C94369A9BF07E985D334708B55D47DBECA64A62E6D0AA68F9E2422,27 Jan 2020 23:30:03 -0000
VERBOSE: Returning: System.Collections.Hashtable
* Removing Items from Idaptive List [ AWS Idaptive Accounts ] ...
VERBOSE: Executing Function: Get-SharePointIdList
VERBOSE: Parameter ListName: AWS Idaptive Accounts
VERBOSE: Executing Command: $Response = Invoke-RestMethod -Uri http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle('AWS Idaptive Accounts')/items -UseDefaultCredentials
VERBOSE: GET http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle('AWS Idaptive Accounts')/items with 0-byte payload
VERBOSE: received -1-byte response of content type application/atom+xml;type=feed;charset=utf-8
VERBOSE: SharePoint List Id: 5b0ec0be-7238-45ef-b7db-032accbb2677
VERBOSE: SharePoint List Id: 1d980706-df50-4ac2-98ee-a124eef0a5ec
VERBOSE: SharePoint List Id: cc79d83a-4ab0-4ea2-b94d-14df34aae624
....
VERBOSE: Executing Function: Delete-SharePointItemsById
VERBOSE: Parameter ListName: AWS Idaptive Accounts
VERBOSE: Parameter ItemIdList: 5b0ec0be-7238-45ef-b7db-032accbb2677 1d980706-df50-4ac2-98ee-a124eef0a5ec cc79d83a-4ab0-4ea2-b94d-14df34aae624 090aa8f4-dadf-4d3d-80df-5ccd9aa0af90 56c7c14b-136b-4968-ab1a-99db0892bf34 c8fa5d34-990d-4afa-95a7-c937fea1a926 b7736
7d6-84dc-484e-81bd-78a0df6bb7b9 08a6fc2a-e124-4c21-aba1-c802aa0ca4b6 e9c935f8-9f9b-4cb7-bd82-01cd518e0186 1781a50e-e351-4332-9023-48d57ba99d2e 4fae3776-d380-4111-9dd4-c78f2bfe5043 9bf0fb16-0577-44ea-a8a7-ad58cf17db4e 8c73c2f8-9850-4ae3-8b9e-91aefdc12e76 4cd0
d3d8-1ba0-4466-8db8-ea952e3f7b8a 75ab9d7e-4b89-446f-8ab1-c7143351bb21 b8bae64e-d953-413c-9cc5-c1d62c6ad5e2 94369ac1-62ac-4013-bc7e-b6bc880f417f 32823411-4fe0-4664-956a-7c53c3185171 9168d632-c9a6-40ef-ba3f-a240947245b0 992ba0a5-0887-4490-9299-4efe942fd6fb 9fd
23d5a-06a4-4326-9a12-77f6886cac56 90ef4012-ae8f-4abd-b419-6864cda3fe72 a7afcc1c-f6a5-4365-9f29-14b1d5a021b5 5aa3ec79-71c6-424d-8651-e56aa399abf9 0176f1e5-8bbc-4e30-84dd-e8dfbc1faa7e 18285b72-e177-4b4c-8af6-5a8dd249877a 3a4978a4-a698-4f22-91de-2ef7e7a3b8b1 e0
4c69a7-3b80-487f-8cca-88e280db19b6 8b6d5c94-013f-4365-9921-aca17f60bd11 1fa16766-cc25-47f2-aae6-02f85cba2b0e 51a24cca-8432-4b37-b8d6-69e2b209205b d643a6d2-5c0e-49b2-bab0-ea5a29664756 ac9eba02-fe28-4e0c-bcf0-50601c33bdca e9475ab7-a297-45b5-810d-ac2dc1580319 5
59f558c-abe5-46df-bb26-ba67f76fa3fb 06cb8d32-4cf4-4abf-b788-41e4b809b1a1 a5100bd1-ac42-4d29-a2bb-82cb9b9fdbcc e2ba3fa8-52fd-4351-a6bb-86b8e100f862 12cb3e5a-46c4-42d9-adf5-4a3c482b28f1 4ea5cc0e-153d-4428-ab52-383ec0c95453 515e1763-bcf9-4bcb-90e0-d0e877815356 
78198224-2367-4441-b833-7872c6be5036 8c089453-c8d7-4bee-b063-cf983b022ccc e271f351-17ea-4a4f-8a38-1382335b2a2f d86694d4-0cd0-4018-9bde-70c0697de3ba cbc857c7-c92b-4c51-b683-045f376009b6 d1d6c934-7561-4754-b2f3-d7b569a55690 ef1738d4-9e2e-49a1-bcc3-0332384bcf74
 404b3986-6b85-4d09-8384-64ada47c4c15 a5ddd055-a90b-40a0-8852-1056c6e21a9b 29552b5e-d123-41c4-9c22-38e0df5f2719 2a74c4d0-9162-4f33-b4e2-2b420559de96 93f0b98a-736d-4a11-a03b-2af99592ab99 b32886ff-0802-4b43-8e19-72b851c0fbe1 32e505ac-b213-41c5-9bbf-11eb0bc7aad
4 1b2f059b-9691-4c33-a57c-e64a71668c51 d9fe0d64-5113-4a62-9b43-9f8489b66070 95a12522-fec9-4ba0-aad6-4c4c05a90b07 e1ed3ba8-e3a8-4ab3-9a71-400409844334 abf8b4fe-819c-4cc2-ad80-522f2c9de57c 50ab4fe7-9345-49fc-8ef0-dcbc9a8e5029 38b54626-a265-4f2e-ba6c-40b8e909cd
4c a948b488-293c-4727-9b2e-c0756758378b 4cee1c15-e5bc-49c1-bc30-ec68d2b56917 1f5f2b8f-2150-468b-bb15-5b3bbf0a0dc2 cdbf7ce3-5268-4f12-be31-cce195a0f2ed 4000273c-658d-4087-8df4-faff05cca2c5
VERBOSE: Parameter Headers: System.Collections.Hashtable
VERBOSE: Executing Command: $Response = Invoke-RestMethod -Uri http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle('AWS Idaptive Accounts')/items5b0ec0be-7238-45ef-b7db-032accbb2677 -UseDefaultCredentials -Method Post -ContentT
ype "application/json" -Headers System.Collections.Hashtable
  - Deleting SharePoint Item: 5b0ec0be-7238-45ef-b7db-032accbb2677
VERBOSE: POST http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle('AWS Idaptive Accounts')/items5b0ec0be-7238-45ef-b7db-032accbb2677 with 0-byte payload

==============================================================================================================
 ERROR: Unable to delete SharePoint List Item [5b0ec0be-7238-45ef-b7db-032accbb2677]: The remote server returned an error: (400) Bad Request.
==============================================================================================================
POST http://sites.example.com/teams/Cloud_Enablement_Program/_api/web/lists/GetByTitle('AWS Idaptive Accounts')/items5b0ec0be-7238-45ef-b7db-032accbb2677