I am trying to update SharePoint document's metadata using '/GetFileByServerRelativeUrl('/sites/sitename/doclib/doc.txt')/ListItemAllFields/ValidateUpdateListItem'
endpoint within my (.netcore) webapi. This requires the date to be in specific format. The problem that I am facing is while I am able to successfully update the date column by transform date into "yyyy-MM-dd hh:mm tt"
, if I try the other format "MM/dd/yyyy hh:mm:ss"
it throws an error:
Invalid Data '02/17/2022 12:29:03' for the field 'Modified', Error: Enter a date and time like this: 2012-02-23 2:25 PM
The reason, I am trying the other format ("MM/dd/yyyy hh:mm:ss"
) is because while it works for one SharePoint site collection (with the format "yyyy-MM-dd hh:mm tt"
), it throws error on other site collection.:
Invalid Data '2022-02-17 12:29:03' for the field 'Created', Error: Enter a date and time like this: 2/23/2012 2:25 PM
where the dates with the format "MM/dd/yyyy hh:mm:ss"
seem to work, which is quite weird.
I have verified, both site collections have identical regional settings.
Is there any universal date format to convert the date into, that I am missing?
Any help is appreciated.
Answering my own question, in case it may help future visitors: I somehow overlooked the
'locale'
setting in site's regional settings. In my case both sites are having different locale which is most likely the cause. So, I am wondering if there's a universal date format e.g. ISO 8601 string (that doesn't work btw) or something that I can use to convert dates into OR custom mapping (site's locale -> Date format) is the only solution for date column update