从 2.1 REST API(可能更早)开始,可以做到这一点。
看到这个答案:
https://sharepoint.stackexchange.com/questions/283332/taxonomyclientservice-is-still-the-way-to-go/287868#287868 或 this article 该答案基于。
编辑:为避免这是一个仅限链接的答案,我复制了以下示例。
术语库组:
要列出:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups
Method : GET
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
创建:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups
Method : POST
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
Body : {"name":"FromRESTAPI", "description":"Description For FromRESTAPI"}
术语集:
要列出:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab- d7a8-479f-9888-8d4421f8218f/sets
Method : GET
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
创建:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets
Method : POST
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
Body : {"description": "","localizedNames": [{"name": "OperationLevel","languageTag": "en-US"}]}
更新:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/dbc06a0b-7f38-42dc-84a7-0b734f350303
Method : PATCH
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
Body : {"description": "Added description","localizedNames": [{"name": "OperationLevelUpdated","languageTag": "en-US"}]}
删除:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/dbc06a0b-7f38-42dc-84a7-0b734f350303
Method : DELETE
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
条款
要列出:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms
Method : GET
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
创建(注意,isDefault 必须为 true 否则会失败):
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/children
Method : POST
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
Body : {"labels": [{"name": "AI","isDefault":true,"languageTag": "en-US"}],"descriptions": [{"description": "AI Innovation","languageTag": "en-US"}]}
要更新(我没用过):
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms/b8b3e828-cdf7-46b2-889e-f5f797a05aa3
Method : PATCH
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
Body : {"labels": [{"name": "AI Updated","isDefault":true,"languageTag": "en-US"}],"descriptions": [{"description": "AI Innovation Updated","languageTag": "en-US"}]}
删除:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms/b8b3e828-cdf7-46b2-889e-f5f797a05aa3
Method : DELETE
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
嵌套条款(我的小贡献)
要列出:
Endpoint : https://testinglala.sharepoint.com/_api/v2.1/termStore/groups/122d92ab-d7a8-479f-9888-8d4421f8218f/sets/8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f/terms/12345678-1234-1234-1234-123456789012/children
Method : GET
Headers : {"Content-Type": "application/json",
"Authorization": "Bearer <Bearer Token>"}
我尚未创建、更新或删除嵌套术语。如果我这样做了,我会更新这个答案。