Skip to content
Snippets Groups Projects
Verified Commit d29d3063 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

update add_list_item return type for sharepoint service

parent 06b92eb2
No related branches found
No related tags found
1 merge request!211Feature/add sharepoint service
......@@ -46,14 +46,20 @@ class SPClient:
.items.get(request_configuration=request_configuration)
)
async def add_list_item(self, list_name: str, fields: dict[str, str]):
async def add_list_item(self, list_name: str, fields: dict[str, str]) -> str:
"""Add a new entry to a SharePoint list.
:param str list_name: The name of the list.
:param dict[str, str] fields: Any pre-filled fields in the list item. Can be left empty.
:return str: The URL of the list in which a new item has been created.
"""
request_body = ListItem(fields=FieldValueSet(additional_data=fields))
return (
new_item = (
await self.client.sites.by_site_id(self.site_id)
.lists.by_list_id(self.list_ids[list_name]).items.post(request_body)
.lists.by_list_id(self.list_ids[list_name])
.items.post(request_body)
)
# Strip the last part of the URL, since we want the link to the list, not the list item.
return new_item.web_url.rsplit("/", 1)[0]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment