Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am stuggling to add items to a sharepoint list #914

Open
sam2332 opened this issue Nov 19, 2024 · 1 comment
Open

I am stuggling to add items to a sharepoint list #914

sam2332 opened this issue Nov 19, 2024 · 1 comment
Labels

Comments

@sam2332
Copy link

sam2332 commented Nov 19, 2024

    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

@DanielEstehghariSopra
Copy link

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?

@vgrem vgrem added the question label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants