Office365-rest-python-client: ๋‹จ์ผ ๋ชฉ๋ก ํ•ญ๋ชฉ์„ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

์— ๋งŒ๋“  2018๋…„ 05์›” 10์ผ  ยท  4์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: vgrem/Office365-REST-Python-Client

SharePoint listitem.py์˜ ์—…๋ฐ์ดํŠธ ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
item_object.update()
ํ•˜์ง€๋งŒ ์—…๋ฐ์ดํŠธํ•˜๋ ค๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์–ด๋–ป๊ฒŒ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? ์˜ˆ๋ฅผ ๋“ค์–ด:
item_properties = {'__metadata': {'์œ ํ˜•': 'SP.Data.'+listTitle+'ListItem'},
'์ œ๋ชฉ': '์ƒˆ ํ•ญ๋ชฉ',
'๊ฐ’':99,
}
๊ทธ๋Ÿฐ ๋‹ค์Œ ํ•ญ๋ชฉ์„ ์—…๋ฐ์ดํŠธํ•˜์‹ญ์‹œ์˜ค ...

question

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด์ „ ์˜ˆ์ œ๋Š” ์ž‘๋™ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์‹ค์ œ ์—…๋ฐ์ดํŠธ ์—†์ด 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()

๋ชจ๋“  4 ๋Œ“๊ธ€

๋‚ด๊ฐ€ ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ์ดํ•ดํ–ˆ๋‹ค๋ฉด ์ด๋ฏธ 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์œผ๋กœ ํ•ด๊ฒฐ๋จ

๊ทธ ์˜ˆ์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค!
ํ•ด๊ฒฐ๋˜์—ˆ์œผ๋ฏ€๋กœ ํ์‡„ํ•  ๊ฒƒ์„ ์ œ์•ˆํ•ฉ๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰