When adding a new listitem or updating an existing one, it is possible to update DateTime fields.
However: it's not clear what the format is for this. using the standard ISO format (yyyy-MM-ddTHH:mm:ssZ) does not work, on listitem add it throws the following error:
Error: Het item bestaat niet. Mogelijk is het door een andere gebruiker verwijderd.
Which occurs because the CLI tries to call the following URL with an actual 0 value:
https://contoso.sharepoint.com/sites/sales/_api/web/lists(guid'<someguid>')/items(0)
On listitem set it simply does not do anything.
But when using the --debug on update and scrolling through the logs, you can find the following:
"data": {
"value": [
{
"ErrorCode": -2146232832,
"ErrorMessage": "Voer een datum en tijd in als volgt: 23-2-2012 14:25",
"FieldName": "SomeDateTimeFieldInternalName",
"FieldValue": "2023-01-18",
"HasException": true,
"ItemId": 3
}
]
}
(Voer een datum en tijd in als volgt = Enter a date and time as follows)
So when executing a listitem add or listitem set with this new information, formatting the date like this: 23-2-2012 14:25 / d-M-yyyy HH:mm it works as expected.
Problem & Solution
The problem is that the responses of the AddValidateUpdateItemUsingPath and ValidateUpdateListItem requests are not evaluated properly. If errors are given in the request calls, the command should throw them and show them to the user.
Also there is a date format that will work in all scenario's: yyyy-HH-mm HH:mm:ss. We should update the documentation and explain how to use datetime fields. (Either in the site locale or this specific format.) We should also explain that the timezone of the site will be used.
To fix this
When adding a new listitem or updating an existing one, it is possible to update DateTime fields.
However: it's not clear what the format is for this. using the standard ISO format (yyyy-MM-ddTHH:mm:ssZ) does not work, on
listitem addit throws the following error:Which occurs because the CLI tries to call the following URL with an actual
0value:https://contoso.sharepoint.com/sites/sales/_api/web/lists(guid'<someguid>')/items(0)On
listitem setit simply does not do anything.But when using the
--debugon update and scrolling through the logs, you can find the following:(Voer een datum en tijd in als volgt = Enter a date and time as follows)
So when executing a
listitem addorlistitem setwith this new information, formatting the date like this:23-2-2012 14:25/d-M-yyyy HH:mmit works as expected.Problem & Solution
The problem is that the responses of the
AddValidateUpdateItemUsingPathandValidateUpdateListItemrequests are not evaluated properly. If errors are given in the request calls, the command should throw them and show them to the user.Also there is a date format that will work in all scenario's:
yyyy-HH-mm HH:mm:ss. We should update the documentation and explain how to use datetime fields. (Either in the site locale or this specific format.) We should also explain that the timezone of the site will be used.To fix this
spo listitem add: The errors given by SharePoint in theAddValidateUpdateItemUsingPathrequest should be returned to the user.spo listitem set: The errors given by SharePoint in theValidateUpdateListItemrequest should be returned to the user.spo listitem batch add: The errors given by SharePoint in theAddValidateUpdateItemUsingPathbatch-request should be returned to the user. The batching should be broken off when an error occurs. (failfast)yyyy-HH-mm HH:mm:ss.