question

AbdulSaifBabu-7422 avatar image
0 Votes"
AbdulSaifBabu-7422 asked ·

Is there a REST API to modify/update readonly properties such as 'Created by' and 'Modified Date' in SharePoint online

We are trying to figure out a way to update the system read-only properties such as 'Created by' and 'Modified Date' in SharePoint. We are using REST API to work with data in SP and hence if there is a REST API to achieve this, it would be great.

We are aware of a workaround to create custom attributes and copy and hide the original columns, but we are looking to understand if there is a REST API way to accomplish this.

office-sharepoint-online
· 7
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AbdulSaifBabu-7422 ,

Is there any update ? Did the code in the answer work to update Created By/ Modified field ?

Thanks
Best Regards

0 Votes 0 ·

Thanks a lot @Jerryzy-MSFT, this did not work properly for updating the system metadata and we have the following observations.

  1. When system fields(Editor, Author, Modified, Created) are updated through REST API
    "<webUrl> + "/_api/web/lists('" + <listGuid> + "')/items(" + <itemId> + ")/ValidateUpdateListItem()", it is returning 200 - success, but actual update of fields only happened once.(Tried for 3 files, with 20 attempts for each file). Only one file's metadata got updated. So the update is very inconsistent. Please note that we 've tried with both SP2019 OnPrem and SP Online.

  2. If only non system (custom) metadata is updated through REST API
    "<webUrl> + "/_api/web/lists('" + <listGuid> + "')/items(" + <itemId> + ")/ValidateUpdateListItem()", it is returning 200 - success and the values are being updated properly every single time.

0 Votes 0 ·

  1. If both system and non-system (custom) metadata is updated, Neither system nor custom metadata is getting updated though 200 is received
    74801-1.png74745-2.png74787-3.png74726-4.png74802-5.png


74669-6.png74670-7.png74754-8.png


0 Votes 0 ·
1.png (65.1 KiB)
2.png (40.5 KiB)
3.png (68.9 KiB)
4.png (79.4 KiB)
5.png (55.2 KiB)
6.png (100.6 KiB)
7.png (77.9 KiB)
8.png (53.0 KiB)
Show more comments
Jerryzy-MSFT avatar image Jerryzy-MSFT AbdulSaifBabu-7422 ·

As the Rest option is not working for the modern site library, so I suggest you could use PowerShell option if possible.

PowerShell will work for both classic/modern site library.

Reference:

SharePoint Online: Update Created By / Modified By, Created / Modified Field Values using PowerShell



I will update the answer also

0 Votes 0 ·

Hi @AbdulSaifBabu-7422 ,

Is there any update ? Have you tried the new suggestion in the comment ?

Thanks
Best Regards

0 Votes 0 ·

1 Answer

Jerryzy-MSFT avatar image
1 Vote"
Jerryzy-MSFT answered ·

Hi @AbdulSaifBadu-7422,

Rest API ValidateUpdateListItem endpoint can be used to update system field (Created/Created By, Modified/Modified By), please see the sample request in PostMan:

Request Url and Header:

73209-snipaste-2021-03-02-12-21-11.png

Request Body:

73210-snipaste-2021-03-02-12-21-44.png

 {
    "formValues":[
       {
          "FieldName":"Author",
          "FieldValue":"[{'Key':'i:0#.f|membership|user@Tenant.onmicrosoft.com'}]"
       },
       {
          "FieldName":"Created",
          "FieldValue":"17/1/2021"
       },
       {
          "FieldName":"Editor",
          "FieldValue":"[{'Key':'i:0#.f|membership|user@Tenant.onmicrosoft.com'}]"
       },
       {
          "FieldName":"Modified",
          "FieldValue":"17/1/2021"
       }
    
    ]
 }

This is the update result with the request above:

73239-snipaste-2021-03-02-12-09-43.png

Here is a blog with the same solution, I suggest you can refer:

How to update created by and modified by field in sharepoint List using REST API

Update: per the deep test, the Rest option above is not working for modern site library, so it's more suggested to use PowerShell(CSOM/PnP PowerShell) to update SharePoint system field, this option is working for both classic/modern library:

SharePoint Online: Update Created By / Modified By, Created / Modified Field Values using PowerShell

Thanks
Best Regards



If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.