我在调用使用 PostMan 获取列表数据的 API 时遇到此错误
https://hostname.sharepoint.com/sites/random_site/_api/web/lists(guid'be7ca91-2715-4b86-8299-7925f99b7536')/items
对于上述请求,下面是回复
{
"odata.error": {
"code": "-2147467259, Microsoft.SharePoint.SPException",
"message": {
"lang": "en-US",
"value": "Cannot complete this action.\n\nPlease try again."
}
}
}
同时,我在使用终端调用 ConnectPnPOnline 时获取同一列表的数据,如下所示作为参考
同时,为了参考,我还附上了下面的一些列表元数据详细信息
{
"odata.metadata": "https://domian.sharepoint.com/sites/random_site/_api/$metadata#SP.ApiData.Lists/@Element",
"odata.type": "SP.List",
"odata.id": "https://domain.sharepoint.com/sites/random_site/_api/Web/Lists(guid'be7ca91-2715-4b86-8299-7925f99b7536')",
"odata.etag": "\"4\"",
"odata.editLink": "Web/Lists(guid'be7ca91-2715-4b86-8299-7925f99b7536')",
"AllowContentTypes": true,
"BaseTemplate": 1331,
"BaseType": 0,
"ContentTypesEnabled": true,
"CrawlNonDefaultViews": false,
"Created": "2022-11-16T11:10:40Z",
"CurrentChangeToken": {
"StringValue": "1;3;be7ca91-2715-4b86-8299-7925f99b7536;638513631004800000;297591295"
},
"DefaultContentApprovalWorkflowId": "00000000-0000-0000-0000-000000000000",
"DefaultItemOpenUseListSetting": false,
"Description": "",
"Direction": "none",
"DisableCommenting": false,
"DisableGridEditing": false,
"DocumentTemplateUrl": null,
"DraftVersionVisibility": 0,
"EnableAttachments": true,
"EnableFolderCreation": true,
"EnableMinorVersions": false,
"EnableModeration": false,
"EnableRequestSignOff": true,
"EnableVersioning": false,
"EntityTypeName": "Model_x0020_Usage",
"ExemptFromBlockDownloadOfNonViewableFiles": false,
"FileSavePostProcessingEnabled": false,
"ForceCheckout": false,
"HasExternalDataSource": false,
"Hidden": false,
"Id": "be7ca91-2715-4b86-8299-7925f99b7536",
"ImagePath": {
"DecodedUrl": "/_layouts/15/images/itgen.gif?rev=47"
},
"ImageUrl": "/_layouts/15/images/itgen.gif?rev=47",
"DefaultSensitivityLabelForLibrary": "",
"SensitivityLabelToEncryptOnDownloadForLibrary": null,
"IrmEnabled": false,
"IrmExpire": false,
"IrmReject": false,
"IsApplicationList": false,
"IsCatalog": false,
"IsPrivate": false,
"ItemCount": 4,
"LastItemDeletedDate": "2024-05-15T05:46:28Z",
"LastItemModifiedDate": "2024-05-15T05:46:28Z",
"LastItemUserModifiedDate": "2024-05-15T05:46:28Z",
"ListExperienceOptions": 0,
"ListItemEntityTypeFullName": "SP.Data.Model_x0020_UsageItem",
"MajorVersionLimit": 0,
"MajorWithMinorVersionsLimit": 0,
"MultipleDataList": false,
"NoCrawl": false,
"ParentWebPath": {
"DecodedUrl": "/sites/random_site"
},
"ParentWebUrl": "/sites/random_site",
"ParserDisabled": false,
"ServerTemplateCanCreateFolders": true,
"TemplateFeatureId": "",
"Title": "Model Usage"
}
我希望通过调用共享点的微软REST API来获取列表项。 但它返回错误 500。
我通过邮递员生成访问令牌,如下所示:
https://login.microsoftonline.com/TenantID/oauth2/v2.0/token
client_id:ClientID
scope:https://tenant.sharepoint.com/.default
grant_type:authorization_code
code:code
redirect_uri:https://jwt.ms
client_secret:ClientSecret
我在 SharePoint 中创建了一个列表:
要列出项目数据,请修改查询,如下所示:
https://tenant.sharepoint.com/sites/testrukk/_api/web/lists/GetByTitle('ruklist')/items?$select=Id,Title,GUID
Accept: "application/json;odata=verbose"
在 PowerShell 中尝试时,我得到了相同的结果:
Get-PnPListItem -List "ruklist"
参考: