Mapping Microsoft SharePoint Content Types Using REST API

Learn how to map SharePoint content types for migration jobs using the DryvIQ REST API.


Overview

SharePoint content types are a type of custom metadata that allows you to categorize files. DryvIQ supports mapping content types between the source and destination. Currently, content type mapping is only available through the DryvIQ REST API.

Retrieving Content Type

You can send a GET request through the REST API to retrieve the metadata schema for a Microsoft SharePoint, Office 365, or OneDrive for Business connection. You can retrieve the metadata schema for a file or folder based on its path, ID, or both. The examples below provide sample code.

GET by File Path

GET {{url}}v1/connections/{connectionID}/files/metadata_schema?path=FilePath

GET by File ID

GET  {{url}}v1/connections/{connectionID}/files/{fileID}/metadata_schema

GET by Folder Path

GET  {{url}}v1/connections/{connectionID}/folders/metadata_schema?path=FolderPath

GET by Folder ID

GET  {{url}}v1/connections/{connectionID}/folders/{folderID}/metadata_schema

The request will return the metadata schema, which includes a field called ContentTypeId. This field will list all possible choices for the content type caption (name) and value pairs. You can use these values to set the ContentTypeId field for a file or folder in the metadata mapping.

},
               "ContentTypeId": {
                   "choices": [
                       {
                           "value": "Document_ID",
                           "caption": "Document"
                       },
                       {
                           "value": "Folder_ID",
                           "caption": "Folder"

Adding Content Types to the Metadata When Creating a Job

To set up content type metadata mapping when creating a job, you must create a choice map that maps the source values to the destination values using the information provided by the GET metadata_schema endpoint. This information is added to the metadata_map in the transfer block.

{
   "transfer": {
           "metadata_map": {
               "schemas": [{
                       "mappings": [{
                               "source": {
                                   "property": {
                                       "name": "ContentTypeId"
                                   }
                               },
                               "destination": {
                                   "property": {
                                       "name": "ContentTypeId"
                                   }
                               },
                               "choices": [{
                                       "source": {
                                           "value": "0x010109008A55C32FB5DB9D4496723A82067F6F4D"
                                       },
                                       "destination": {
                                           "value": "0x010100C2138012BBD4B4439BD03ABF3FF6BCC7008AA8EF10A21C2042AC4CEC551BCA11F0"
                                       }
                               }
                           ]
                       }
                   ]
               }
           ]
       }
   }
}

Content Type ID

Use each content type ID only once. Listing the same content type ID twice will cause a duplicate database key error. This can happen if you duplicate a job with an existing content type map and then use the Advanced Scripting page in the UI to add JSON to map the content types again.