question

NagavalliPuli-7205 avatar image
0 Votes"
NagavalliPuli-7205 asked RaytheonXie-MSFT commented

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

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


office-sharepoint-server-developmentsharepoint-devsharepoint-workflow
modified-by.jpg (184.8 KiB)
· 1
5 |1600 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 @NagavalliPuli-7205 ,
I am currently doing some research on this issue, will let you know as soon as possible

0 Votes 0 ·
NagavalliPuli-7205 avatar image
0 Votes"
NagavalliPuli-7205 answered

@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



5 |1600 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.

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered NagavalliPuli-7205 commented

Hi @NagavalliPuli-7205 ,
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://docs.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://docs.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.




· 1
5 |1600 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.

@RaytheonXie-MSFT is there any way I can update SP.Taxonomy, and file modified by field
"I found that the rest api only works for list" -- but we are storing files in folders, how can convert relative path to list

sites/shared documents/test folder/child1/abc.txt

how can I convert the above path as list?



0 Votes 0 ·
RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered RaytheonXie-MSFT commented

Hi @NagavalliPuli-7205 ,
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.




· 2
5 |1600 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.

@RaytheonXie-MSFT I need to update modified by from Angular 8 code (REST API),

using Client ID and Token, and user office Email


0 Votes 0 ·
RaytheonXie-MSFT avatar image RaytheonXie-MSFT NagavalliPuli-7205 ·

Hi @NagavalliPuli-7205 ,
Per my research, there is no such function to update modified by in library by rest api. I feel regretful to inform you that it turns out to be a by-design one.

0 Votes 0 ·