Hi @Leung1975 ,
Rest API can only update field when ReadOnlyField property set to false, please check this similiar thread:
Update readonly field using REST API
A workaround would be using SharePoint Online CSOM to update Read-Only field value:
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$siteURL = "https://tenant.sharepoint.com"
$userId = "user@tenant.onmicrosoft.com"
$pwd = Read-Host -Prompt "Enter password" -AsSecureString
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd)
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)
$ctx.credentials = $creds
try{
$lists = $ctx.web.Lists
$list = $lists.GetByTitle("doc1")
$listItem = $list.GetItemById(7)
$listItem["Column2"] = "UpdateForReadOnly2"
$listItem["Column3"] = "UpdateForReadOnly3"
$listItem["Column4"] = "UpdateForReadOnly4"
$listItem.Update()
$ctx.load($listItem)
$ctx.executeQuery()
}
catch{
write-host "$($_.Exception.Message)" -foregroundcolor red
}
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.