How to update a date attribute in SharePoint through the REST API in JSON

Karim 21 Reputation points
2020-08-05T15:34:31.833+00:00

We are making use of the REST API interface of SharePoint to update metadata of documents. We do this in JSON. A typical example of udpate is the following:
POST on
/_api/web/GetFileById('<doc_id_guid>')/ListItemAllFields/ValidateUpdateListItem'

and the body is as follows:

{ 'formValues' : [
{ 'FieldName' : 'User' , 'FieldValue' : 'KA' } ,
{ 'FieldName' : 'Source' , 'FieldValue' : 'QualityNotification' } ,
{ 'FieldName' : 'ReportDate' , 'FieldValue' : '2020-03-30T00:00:00' } ,
{ 'FieldName' : 'Title' , 'FieldValue' : 'Created by user KA' }
] , 'bNewDocumentUpdate' : true }

It works fine with all attributes excepted with the 'ReportDate'. This one is defined as Date and Time (all others are Single line of text) and we cannot succeed in getting this attribute updated, it is always left empty.
We've tried the above date format, but also with other formats such as '2020-03-30T00:00:00Z' and '2020-03-30T00:00:00.000Z', and also with '/Date(1335205592410)/' and '/Date(1335205592410)/', nothing works !
The system indicates there is an error but does not specify which one...

So how can we get this Date and Time attribute updated ???

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,770 questions
0 comments No comments
{count} votes

Accepted answer
  1. Baker Kong-MSFT 3,801 Reputation points
    2020-08-06T02:28:15.427+00:00

    Hi Karim-2979,

    It seems that ISO date format is not supported, i also get error when update date column using '2020-03-30T00:00:00'

    15991-image.png

    The following formats are accepted:

    15992-image.png

    15974-image.png

    More Reference:

    Best Regards,
    Baker Kong

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.