You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Microsoft Graph为文件的TaxKeyword字段设置Term

解决Microsoft Graph更新文件TaxKeyword字段的问题

核心问题

你的PATCH请求格式错误,Managed Metadata字段(如TaxKeyword)在Microsoft Graph中需要特定结构,且必须包含WssId参数,仅提供Label和TermGuid会触发invalidRequest错误。

正确操作步骤

1. 获取目标Term的WssId

WssId是Term在当前站点文档库中的本地标识,需通过以下Graph接口获取:

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/Documents/fields/getByInternalNameOrTitle('TaxKeyword')/?$select=choices

返回结果的choices数组中,找到对应Term的WssId值即可。

2. 发送正确的PATCH请求

使用获取到的WssId,构造如下请求体(无需添加@odata.type声明):

{
    "fields": {
        "TaxKeyword": [
            {
                "TermGuid": "1b20b62d-7ee9-4f55-9ecf-88e622a3f7d7",
                "WssId": 1 // 替换为实际获取到的WssId
            }
        ]
    }
}

请求地址保持为:

PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/Documents/items/{item-id}

补充说明

  • 若需添加多个Term,直接在TaxKeyword数组中追加更多{TermGuid, WssId}对象即可。
  • 新创建的Term需等待几秒同步到目标站点文档库后,才能查询到对应的WssId。

内容的提问来源于stack exchange,提问作者martirodm

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 10:02:42