Skip to content

listitem <verb> commands do not handle errors that are returned by POST's to the REST API #4375

@martinlingstuyl

Description

@martinlingstuyl

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

  • spo listitem add : The errors given by SharePoint in the AddValidateUpdateItemUsingPath request should be returned to the user.
  • spo listitem set : The errors given by SharePoint in the ValidateUpdateListItem request should be returned to the user.
  • spo listitem batch add : The errors given by SharePoint in the AddValidateUpdateItemUsingPath batch-request should be returned to the user. The batching should be broken off when an error occurs. (failfast)
  • The documentation of the commands should explain to use the date time format of the site locale or yyyy-HH-mm HH:mm:ss.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions