简体   繁体   English

用于获取自定义元数据列的SharePoint REST API

[英]SharePoint REST API for Fetching custom Metadata Columns

I am Developing a plugin that exports Documents to SharePoint Repository after processing them. 我正在开发一个在处理文档后将文档导出到SharePoint存储库的插件。 Along with the document, I need to send values for Custom Metadata columns defined in SharePoint. 与文档一起,我需要发送SharePoint中定义的“自定义元数据”列的值。

I have figured out how to send across Files and Metadata to a specified location. 我已经弄清楚了如何跨文件和元数据发送到指定位置。

Problem: Initially, I do not know what custom metadata columns are available in the given folder. 问题:最初,我不知道给定文件夹中有哪些自定义元数据列。 Could someone shed light on any REST webservice that can fetch the available Metadata Columns for a given location in the repository. 有人可以阐明任何可以获取存储库中给定位置的可用元数据列的REST Web服务。

Note: I am using pure Java for REST Requests using Apache HTTP Client. 注意:我正在使用纯Java来使用Apache HTTP Client进行REST请求。

The REST url for retrieving the custom fields in a list is: 用于检索列表中的自定义字段的REST网址是:

_api/web/lists/GetByTitle('Custom List')/fields

I don't know much about parsing JSON in java but this will give you a list of all the columns and extensive details about them. 我对使用Java解析JSON不太了解,但这将为您提供所有列的列表以及有关它们的详细信息。 I displayed some of the data returned below. 我显示了下面返回的一些数据。

DefaultValue : null
Description : ""
EnforceUniqueValues : false
Id : "fa564e0f-0c70-4ab9-b863-0177e6ddd123"
Indexed : false
InternalName : "Title"
ReadOnlyField : false
Required : false
StaticName : "Title"
Title : "Title"
FieldTypeKind : 2
TypeAsString : "Text"
TypeDisplayName : "Single line of text"

If you need to get the available columns of a specific folder, and not a library: 如果需要获取特定文件夹而不是库的可用列:

_api/web/getfolderbyserverrelativeurl('/Shared%20Documents/Folder')/ListItemAllFields

SharePoint 2013 has a REST API endpoint that could retrieve and filter Metadata columns if you obtain the information through a POST request using CAML . SharePoint 2013具有REST API终结点,如果您使用CAML通过POST请求获取信息,则该REST API终结点可以检索和筛选元数据列。 If your requests were made from SharePoint itself, you would use the masterpage's RequestDigest , but since you are doing it remotely, you would have to get this parameter by querying /_api/contextinfo and obtaining the FormDigestValue . 如果您的请求是从SharePoint本身发出的,则可以使用母版页的RequestDigest ,但是由于是远程进行的,因此必须通过查询/_api/contextinfo并获取FormDigestValue来获取此参数。 Here is an article on it: 这里是一篇文章:

http://www.cleverworkarounds.com/2013/09/23/how-to-filter-on-a-managed-metadata-column-via-rest-in-sharepoint-2013/ http://www.cleverworkarounds.com/2013/09/23/how-to-filter-on-a-managed-metadata-column-via-rest-in-sharepoint-2013/

Also, you must enable CORS on your SharePoint data repository. 另外,您必须在SharePoint数据存储库上启用CORS

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM