Цель: чтение значений полей (столбцов) из библиотеки SharePoint.
Код приведен ниже. При печати «полей» отображаются все, но при печати «item.properties» отображаются только некоторые поля, многие из которых «Нет» (обязательно доступны в Интернете).[![screenshot][1]][1]
Дополнительная информация: как ни странно, этот код работает (т. е. показывает все значения полей) в другой библиотеке в той же точке доступа.
Спасибо!
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
# Replace these variables with your SharePoint details
site_url = "https://xx.sharepoint.com/sites/xx"
username = "xx@xx"
password = r"xx"
# Authenticate and establish connection
ctx_auth = AuthenticationContext(site_url)
if ctx_auth.acquire_token_for_user(username, password):
ctx = ClientContext(site_url, ctx_auth)
print("Connection established successfully.")
else:
print("Authentication failed.")
# Specify the library name
library_name = "Reports"
# Get the library
library = ctx.web.lists.get_by_title(library_name)
ctx.load(library)
ctx.execute_query()
# Get all fields (columns) of the library
fields = library.fields
ctx.load(fields)
ctx.execute_query()
# Display column details
print("Columns in the Library:")
print(fields) # --> OK, all fields are listed
# Access items in the library
items = library.items.paged(50)
ctx.load(items)
ctx.execute_query()
items[0].properties # --> shows some of the fields, many of them are "None"
[1]: https://i.sstatic.net/pzIj0rBf.png
Подробнее здесь: https://stackoverflow.com/questions/792 ... any-fields
Чтение данных поля из Sharepoint с помощью Python — отсутствует или отсутствует для многих полей ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение