SharePoint listitem.py์ ์
๋ฐ์ดํธ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
item_object.update()
ํ์ง๋ง ์
๋ฐ์ดํธํ๋ ค๋ ๋ฐ์ดํฐ๋ฅผ ์ด๋ป๊ฒ ๋ฃ์ ์ ์์ต๋๊น? ์๋ฅผ ๋ค์ด:
item_properties = {'__metadata': {'์ ํ': '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 ์๋ต ์ฝ๋๋ฅผ ๋ฐ์์ต๋๋ค.
์ฌ๋ฐ๋ฅธ ๋ฐฉ๋ฒ - ๋ฉ์๋๋ฅผ ํตํด ๊ฐ์ฒด ์์ฑ ์ค์ :