Reputation: 23
I am Developing a plugin that exports Documents to SharePoint Repository after processing them. Along with the document, I need to send values for Custom Metadata columns defined in 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.
Note: I am using pure Java for REST Requests using Apache HTTP Client.
Upvotes: 0
Views: 6245
Reputation: 710
The REST url for retrieving the custom fields in a list is:
_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. 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
Upvotes: 2
Reputation: 1192
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
. 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
. Here is an article on it:
Also, you must enable CORS
on your SharePoint data repository.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Upvotes: 0