Node.js 从原始odata响应中删除与Sharepoint相关的属性
我正在使用Sharepoint REST API从NodeJS获取/修改Sharepoint中的数据 我收到来自Sharepoint REST API的odata响应,一切正常。 除了一件事 目前我从Sharepoint REST API得到如下响应Node.js 从原始odata响应中删除与Sharepoint相关的属性,node.js,sharepoint,odata,Node.js,Sharepoint,Odata,我正在使用Sharepoint REST API从NodeJS获取/修改Sharepoint中的数据 我收到来自Sharepoint REST API的odata响应,一切正常。 除了一件事 目前我从Sharepoint REST API得到如下响应 { "odata.metadata": "https://test.sharepoint.com/_api/$metadata#SP.ApiData.Lists", "value": [ {
{
"odata.metadata": "https://test.sharepoint.com/_api/$metadata#SP.ApiData.Lists",
"value": [
{
"odata.type": "SP.List",
"odata.id": "https://test.sharepoint.com/_api/Web/Lists(guid'sample-guid')",
"odata.etag": "\"6\"",
"odata.editLink": "Web/Lists(guid'sample-guid')",
"AllowContentTypes": true,
"BaseTemplate": 160,
"BaseType": 0,
"ContentTypesEnabled": true,
"CrawlNonDefaultViews": false,
"Created": "2015-05-19T11:13:46Z",
"DefaultContentApprovalWorkflowId": "00000000-0000-0000-0000-000000000000",
"Description": "Use this list to track access requests to a site or uniquely permissioned items in the site.",
"Direction": "none",
"DocumentTemplateUrl": null,
"DraftVersionVisibility": 0,
"EnableAttachments": false,
"EnableFolderCreation": false,
"EnableMinorVersions": false,
"EnableModeration": false,
"EnableVersioning": true,
"EntityTypeName": "AccessRequests",
"FileSavePostProcessingEnabled": false,
"ForceCheckout": false,
"HasExternalDataSource": false,
"Hidden": true,
"Id": "sample-id",
"IrmEnabled": false,
"IrmExpire": false,
"IrmReject": false,
"IsApplicationList": false,
"IsCatalog": false,
"IsPrivate": false,
"ItemCount": 1,
"LastItemDeletedDate": "2015-05-19T11:13:46Z",
"LastItemModifiedDate": "2015-08-04T06:57:22Z",
"ListItemEntityTypeFullName": "SP.Data.AccessRequestsItem",
"MajorVersionLimit": 0,
"MajorWithMinorVersionsLimit": 0,
"MultipleDataList": false,
"NoCrawl": true,
"ParentWebUrl": "/",
"ParserDisabled": false,
"ServerTemplateCanCreateFolders": true,
"TemplateFeatureId: "sample-id",
"Title": "Test Title"
}, {
........
}]
}
在上面的回复中,我得到了与Sharepoint系统相关的字段以及我想要的字段。
例如:odata.type、odata.id、AllowContentTypes、BaseTemplate等
如何获取所需的字段,而不获取其他Sharepoint相关字段
有人能帮忙吗
为此,您可以使用$select查询选项follow了解更多详细信息 关于odata.type和odata.id属性,因为它们是 对于元数据属性,您只需要指定适当的Accept 标题以请求它们,例如:接受: 应用程序/json;odata=最小元数据。有关更多详细信息,请参阅本文 以下示例返回一组特定的列表资源属性,例如AllowContentTypes和BaseTemplate: 结果
为什么要调用/_api/$metadataSP.ApiData.Lists而不是/_api/web/Lists?我只调用/_api/web/Lists。我只想在响应中获取特定于用户的字段,而不是特定于Sharepoint的字段。请详细说明“特定于用户的字段”和“特定于Sharepoint的字段”是什么?此外,从我的回答中不清楚如何检索odata.type、odata.id、AllowContentTypes、,BaseTemplate属性?实际上,我正在尝试将Sharepoint REST API端点动态映射到expressjs路由。在这种情况下,我不知道用户想要什么字段。所以在URL中,我将无法使用$select。
Endpoint URI: https://contoso.sharepoint.com/_api/web/lists?$select=AllowContentTypes,BaseTemplate
Accept: application/json; odata=minimalmetadata
Method: GET
{
"d": {
"results": [
{
"__metadata": {
"id": "https://contoso.sharepoint.com/_api/Web/Lists(guid'82dcfcc5-e58c-4610-b4c3-589a7228e912')",
"uri": "https://contoso.sharepoint.com/_api/Web/Lists(guid'82dcfcc5-e58c-4610-b4c3-589a7228e912')",
"etag": "\"0\"",
"type": "SP.List"
},
"AllowContentTypes": true,
"BaseTemplate": 125
},
//...
]
}
}