Unfortunately this method does not work for the author field in document library
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.
2 answers
Sort by: Newest
-
-
Jerryzy 10,566 Reputation points
2021-03-02T05:49:48.977+00:00 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:
Request Body:
{ "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:
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.