简体   繁体   中英

Microsoft Graph API get list of columns associated with a content type

Is it possible through the Microsoft Graph API to enumerate the columns associated with a content type? For example, you can enumerate the columns for a particular document library using the following endpoint

https://graph.microsoft.com/v1.0/drives/{drive id}/list?$expand=columns

The response will contain an array of available columns something like the following

"columns": [
  ...
  {
    "columnGroup": "Custom Columns",
    "description": "",
    "displayName": "Title",
    "enforceUniqueValues": false,
    "hidden": false,
    "id": "fa564e0f-0c70-4ab9-b863-0177e6ddd247",
    "indexed": false,
    "name": "Title",
    "readOnly": false,
    "required": false,
    "text": {
      "allowMultipleLines": false,
      "appendChangesToExistingText": false,
      "linesForEditing": 0,
      "maxLength": 255
    }
  },
  ...

This works fine for document libraries that have only a single content type, but I am working with libraries that may use multiple content types and I need to be able to list the columns that are associated with each content type.

The basic issue is that our app will upload documents to SharePoint and then try to update the metadata on those documents by setting the fields in the document's list item, ie,

PATCH https://graph.microsoft.com/v1.0/drives/{drive id}/items/{item id}/listitem
{
  "fields": {
    "Comments": "comments",
    "Title": "document title"
    ...
  }
}

However, the list of fields to be updated by our app is dynamic, and if a field is included in this call that does not exist in the libraries columns, the call will fail. For example, if the target content type does not have a Comments column, the call would return this error

{
  "error": {
    "code": "invalidRequest",
    "message": "Field 'Comments' is not recognized",
    "innerError": {
      "date": "2020-12-11T15:55:57",
      "request-id": "35fa6322-caa8-48b8-b2bd-59e3dd4e0c93",
      "client-request-id": "35fa6322-caa8-48b8-b2bd-59e3dd4e0c93"
    }
  }
}

So I need to determine which fields are available before trying to update their values so they can be excluded from the call.

Directly through graph call its not possible as of now. Please raise a uservoice in the Microsoft Graph feedback forum so that the product team may implement it in future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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