我正在使用以下代码将项目添加到SharePoint列表:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.runtime.client_request import ClientRequest
from office365.runtime.utilities.request_options import RequestOptions
from office365.sharepoint.client_context import ClientContext
app_settings = {
'url': 'url',
'client_id': 'clientid',
'client_secret': 'secret'
}
context_auth = AuthenticationContext(url=app_settings['url'])
context_auth.acquire_token_for_app(client_id=app_settings['client_id'], client_secret=app_settings['client_secret'])
ctx = ClientContext(app_settings['url'], context_auth)
print("Create list item example...")
list_object = ctx.web.lists.get_by_title("listtitle")
item_properties = {'__metadata': {'type': 'SP.List'}, 'Title': 'Task Created by Python Script',
'CategoryDescription': 'This is a test Task created by Python script with the help of Office 365 library.'}
我可以用上面的代码成功地将项目添加到列表中。你知道吗
现在,当我尝试用下面这样的多选值传递时,它不起作用
item_properties = {'__metadata': {'type': 'SP.List'}, 'Title': '01 Task Created by Python Script', 'CategoryDescription': 'This is a test Task created by Python script with the help of Office 365 library.'
'ChoiceField':{
'__metadata' : {'type' : 'Collection(Edm.String)' },
'results': ['value 1', 'value 2']
}
}
执行上述操作时,收到以下错误:
An open collection property 'ChoiceField' was found. In OData, open collection properties are not supported.", "400 Client Error: Bad Request for url:..."
找不到解决办法。有人能帮我解决这个问题吗?你知道吗
更新:我甚至在Python office-365 libraray的Github页面上提出了这个问题。问题可以找到here
我不擅长使用python和sharepoint API, 但似乎您正在尝试将一个项目添加到列表中,同时还添加了一些选项。 我相信这个列表应该与choices字段一起存在,添加时只需添加您为添加的项目选择的选项。你知道吗
我希望能有所帮助。你知道吗
相关问题 更多 >
编程相关推荐