python sharepoint 获取术语库

问题描述 投票:0回答:1

我正在尝试创建一个小型 python 程序来获取列表内容。 直到一切正常,除了.. 有些列是来自术语存储的查找列,因此我想获取术语存储值以将它们加入到我的获取列表结果中,以获得查找值而不是术语 id

到目前为止,我的代码使用的是 Office365-REST-Python-Client==2.4.4 版本

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
import pandas as pd
import sys

sharepoint_url = "https://my url/sites/mysite"
library_name = "MyDocumentLibrary"
auth_context = AuthenticationContext(sharepoint_url)
try:
    if auth_context.acquire_token_for_user(username, password):
        # Successfully acquired the token
        print("Successfully authenticated")
        # Create a SharePoint client context
        ctx = ClientContext(sharepoint_url, auth_context)
        library = ctx.web.lists.get_by_title(library_name)
        ctx.load(library)
        items = library.get_items()
        ctx.load(items)
        # Execute the query to fetch library and items metadata
        ctx.execute_query()
        # Create a list to store the data
        data = []

        # Extract and store item data in the list
        for item in items:
            data.append(item.properties)
    
        # Create a pandas DataFrame from the list
        df = pd.DataFrame(data)

        ######## Collect Term store to replace GUID with term value #######
        
    else:
        print("Failed to authenticate")
        sys.exit()
except Exception as e:
    print(f"Failed to connect: {str(e)}")
    sys.exit()

从这里我就陷入了困境,这是一个企业 Office 365 环境,所以我只有我的用户名和密码。我无法访问客户端密钥或客户端 ID 来创建 API 请求。理想情况下,我将使用 ctx 上下文客户端来获取术语库和他的孩子。但这种情况下没有文档。

谢谢你的帮助

python office365
1个回答
0
投票

Pudistes Solucionarlo yo tambien ando Buscando la manera pense que se podria con shareplum pero parece que no se puede

© www.soinside.com 2019 - 2024. All rights reserved.