Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

I am stuggling to add items to a sharepoint list

Open sam2332 opened this issue 1 year ago • 1 comments

    client = GraphClient(get_client)
    site = client.sites
    site = site.get_by_url('https://inghamcnty.sharepoint.com/sites/EmployeeDirectory')
    lists = site.lists
    directory_list = lists.get_by_name("Directory")    # Retrieve items from the list
    # Access the items collection
    items = directory_list

    print(type(directory_list))
   
    print(inspect.getfile(directory_list.__class__))
    item = directory_list.add_item({
        "Title": title,
        "Description": description
    }).execute_query()
    print(f'Item has been added with id: {item.id}')

I feel like i am close but then i look at the types they are always onedrive based and never sharepoint based

from office365.onedrive.sites.site import Site
class SitesWithRoot(EntityCollection[Site]):
    """Sites container"""

these lines in onedrive/sites/sites_with_root.py show how its not using a base object for inheritance causing it to not switch.

or maybe im not understanding how to do sharepoint lists properly

sam2332 avatar Nov 19 '24 21:11 sam2332

In the v2 SharePoint API they are synonymous. Your code should be working, I managed to do the same thing yesterday. Do you get an exception when you try the provided approach?

DanielEstehghariSopra avatar Dec 05 '24 10:12 DanielEstehghariSopra