Unable to update SharePoint List items using shareplum

1.2k Views Asked by At

I have a Python script that I've been running for months that uses shareplum to update various columns of a SharePoint List using UpdateListItems(kind = 'Update'). It has suddenly stopped working and I've no idea why. I don't get any error messages but the changes I am trying to make are not showing up. Creating a new item is working fine, it's only when I try to update an existing list item. I use the Office365 version of SharePoint.

The List is relatively large with over 500 list items and over 100 columns. The maximum List ID is 1050.

I tested it on another smaller list and it works OK, so it must be an issue with this particular List.

I'd be really grateful if someone could help. Since I'm not getting any error messages I don't know how to check what could be wrong with it.

from shareplum import Site
from shareplum import Office365
    

authcookie = Office365('https://XXX.sharepoint.com', username= XXX, password= XXX).GetCookies()
site = Site('https://XXX.sharepoint.com/sites/XXX', authcookie=authcookie)
list_ = site.List('TestList')

my_data = [{'ID': '3', 'Title': 'TestTitle'}]
list_.UpdateListItems(data=my_data, kind='Update')

UPDATE: I printed off the result of the response which says '0x80070057', 'Bad parameter passed to Web Server Extensions. Check the information you entered and try again.' I'm not sure if this helps identify what the issue could be?

I am now able to update my List items using Office365-REST-Python-Client instead of shareplum, but still love to know what the issue with shareplum is.

1

There are 1 best solutions below

1
Zain On

Idk Python, but PowerShell/CSOM allows you to update the item after you have made the update. I'm assuming Shareplum is a wrapper for CSOM, so you should still have the ability to manually trigger the update.

I don't remember the code of the top of my head, but to manually update it it's something like this (in CSOM):

$listItem = get-pnplistitem -Identity 1 -list "Documents"
$listItem.Fields["Title"] = "New Title"
$listItem.Update()
$listItem.context.executeQuery()