System update Author in SharePoint List
Hi
First of all, thanks for this great library which has helped me a lot so far!
I am trying to set the Created By / Author of a file/list item. I have followed the example here: https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/listitems/system_update_item.py
This is my code:
ctx = ClientContext(site_url).with_credentials(client_credentials) list = ctx.web.lists.get_by_title("DropOff") item = list.get_item_by_id(2834) author = ctx.web.site_users.get_by_email("[email protected]") modified_date = datetime.utcnow()
result = item.validate_update_list_item({ "Title": "Test", "Author": FieldUserValue.from_user(author), "Modified": modified_date }, dates_in_utc=True ).execute_query()
I get this error:
Exception has occurred: TypeError validate_update_list_item() got an unexpected keyword argument 'dates_in_utc'
I have also tried to remove "dates_in_utc" and add "new_document_update=True" instead (I have also tried to set it to False):
ctx = ClientContext(site_url).with_credentials(client_credentials) list = ctx.web.lists.get_by_title("DropOff") item = list.get_item_by_id(2834) author = ctx.web.site_users.get_by_email("[email protected]") modified_date = datetime.utcnow()
result = item.validate_update_list_item({ "Title": "Test", "Author": FieldUserValue.from_user(author), "Modified": modified_date }, new_document_update=True ).execute_query()
This gives me this error:
Exception has occurred: TypeError Object of type FieldUserValue is not JSON serializable
Can anyone please tell me what I am doing wrong or if there is an alternative way to set the Created By / Author of an item?
Best regards, Tobias
Greetings,
good to know you found the library useful :)
Regarding the errors, most likely they occur since outdated version of library is utilized, at least dates_in_utc parameter has been introduced in the recent release (2.3.12)
Anyway would suggest to upgrade to the latest one and the provided errors should no longer occur

Hi vgrem,
Thanks for your quick reply!
I have just upgraded to 2.3.12. Now I don't get the error anymore, and I can see the document is modified as shown in the below picture, but the Author/Created By is not changed.
(Version 13 is made with the set_property function)
Do you have an idea what the issue might be? Is it because it is a document library?
Best regards, Tobias
Although this is an old post, but if someone stumble upon this issue, try also specify dates_in_utc=True to ensure dates are specified in UTC format.
Example: system_update.py
@TobiasObton , did you ever get the Author field not setting sorted out? I'm having similar issues right now, I cannot change Author/Editor fields at all.