update modified by(user type field) and security classification (taxonomy filed) using rest API

Nagavalli Puli 1 Reputation point
2022-06-23T06:47:37.477+00:00

hi Team,

I am trying to update user type field modified by and taxonomy field Security_x0020_Classification using SharePoint REST API call using OAuth token. but I am unable to do that please find the screenshot

214193-securityclassfication.jpg

214232-modified-by.jpg

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,657 questions
SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
507 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,569 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Nagavalli Puli 1 Reputation point
    2022-06-24T03:40:31.07+00:00

    @RaytheonXie_MSFT Thank you for your support, this would be a great help, if you provide me the documentation how can I update file 'modified by' and 'security classification' fields. using relative path.

    214550-error-modifiedby.png

    0 comments No comments

  2. RaytheonXie_MSFT 30,751 Reputation points Microsoft Vendor
    2022-06-24T06:27:57.757+00:00

    Hi @Nagavalli Puli ,
    Per my research, The REST API does not currently support working with Managed Metadata or Taxonomy fields. If you look at the REST API reference you'll find no mention of SP.Taxonomy or anything under SP.Taxonomy
    https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-rest-reference/jj860569(v=office.15)?redirectedfrom=MSDN

    After trying to update 'modified by', I found that the rest api only works for list but not document library. Here is a similar issue with yours for reference.
    https://learn.microsoft.com/en-us/answers/questions/293328/is-there-a-rest-api-to-modifyupdate-readonly-prope.html

    As a workaround, you can update 'modified by' by powershell
    https://www.sharepointdiary.com/2016/11/update-created-by-modified-by-created-at-modified-at-values-using-powershell.html

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.



  3. RaytheonXie_MSFT 30,751 Reputation points Microsoft Vendor
    2022-06-27T07:56:42.36+00:00

    Hi @Nagavalli Puli ,
    For modified by field, you can refer to the following powershell script

    #Load SharePoint CSOM Assemblies  
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"  
    Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"  
         
    ##Variables for Processing  
    $SiteUrl = "https://crescent.sharepoint.com/sites/sales/"  
    $ListName= "Projects"  
    $ID=6  
    $UserID="Salaudeen@crescent.com"  
    $TimeStamp = "2015/12/01 02:10:00 AM"  
       
    #Get Credentials to connect  
    $Cred = Get-Credential  
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)  
       
    #Setup the context  
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)  
    $Ctx.Credentials = $Credentials  
       
    #Get the User  
    $User = $Ctx.Web.EnsureUser($UserID)  
    $ctx.Load($user)  
       
    #Get the list Item  
    $List=$Ctx.Web.Lists.GetByTitle($ListName)  
    $ListItem = $List.GetItemById($ID)  
    $Ctx.Load($ListItem)  
       
    #update created by column sharepoint online powershell  
    $ListItem["Author"] = $User  
    #Update Modified By  
    $ListItem['Editor'] = $User  
       
    #Set Created on & Modified on Time values  
    $ListItem["Created"] =  $TimeStamp  
    $ListItem["Modified"] = $TimeStamp  
       
    #Update List item  
    $ListItem.Update()  
    $ctx.ExecuteQuery()  
       
    Write-host "Metadata values updated Successfully!" -f Green  
    

    For SP.Taxonomy, as far as I know, there is no such function to update Taxonomy by rest api after doing some research.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.