SharePointlistitem.pyの更新メソッドを使用しています
item_object.update()
しかし、更新したいデータをどのように配置できますか? 例えば:
item_properties = {'__metadata':{'type': 'SP.Data。' + listTitle + 'ListItem'}、
'タイトル': '新しいアイテム'、
「値」:99、
}
次に、アイテムを更新します...
私が正しく理解している場合は、Sharepointと既に同期されているオブジェクトを更新する必要があります。 これが私がそれを達成した方法です:
ctx_auth = AuthenticationContext(url=sharepoint_site_url)
ctx = ClientContext(sharepoint_site_url, ctx_auth)
target_list = ctx.web.lists.get_by_title(sharepoint_root_folder_name)
# Fetch item by id and add properties to it.
item = target_list.get_item_by_id(item_id)
item.properties.update({
"NewItem": "99"
})
item.update()
ctx.execute_query()
前の例は私には機能しません-実際の更新なしで204の応答コードを取得しました。
正しい方法-メソッドを介してオブジェクトのプロパティを設定します。
# Open list object from portal
ctx_auth = AuthenticationContext(url=sharepoint_site_url)
ctx = ClientContext(sharepoint_site_url, ctx_auth)
target_list = ctx.web.lists.get_by_title(sharepoint_root_folder_name)
# Fetch list item object by id and set it's properties
item = target_list.get_item_by_id(item_id)
item.set_property('Title', 'new-title')
item.set_property('NewItem', '99')
# Update list item object and send request back to portal
item.update()
ctx.execute_query()
#146で解決
それらの例をありがとう!
決議されたので閉鎖することを提案します。
最も参考になるコメント
前の例は私には機能しません-実際の更新なしで204の応答コードを取得しました。
正しい方法-メソッドを介してオブジェクトのプロパティを設定します。