%3CLINGO-SUB%20id%3D%22lingo-sub-1365682%22%20slang%3D%22en-US%22%3EUpdate%20file%20metadata%20with%20Rest%20API%20using%20ValidateUpdateListItem%20in%20SharePoint%20on-premises%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1365682%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EThis%20post%20is%20a%20contribution%20from%20Aaron%20Mio%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELately.%20I%20came%20across%20an%20issue%20of%20using%20REST%20API%20%3CEM%3EValidateUpdateListItem()%3C%2FEM%3E%20to%20update%20listitem%20metadata.%20There%E2%80%99re%20a%20few%20blogs%20published%20on%20method%20%3CEM%3EValidateUpdateListItem()%3C%2FEM%3E%20for%20%3CEM%3ESharePoint%20Online%3C%2FEM%3E.%20A%20few%20benefits%20of%20using%20%3CEM%3EValidateUpdateListItem%3C%2FEM%3E%20are%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EUpdate%20list%20items%20without%20increasing%20its%20item%20version%20(see%20%3CA%20href%3D%22https%3A%2F%2Fwww.c-sharpcorner.com%2Farticle%2Fupdate-a-sharepoint-list-item-without-increasing-its-item-file-version-using-res%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20blog%3C%2FA%3E%20for%20details).%3C%2FLI%3E%0A%3CLI%3EEasier%20to%20update%20some%20types%20of%20metadata%2C%20like%20Taxonomy%2C%20People%20and%20Lookup%20fields%20(mentioned%20in%20%3CA%20href%3D%22https%3A%2F%2Frobertschouten.com%2F2018%2F04%2F30%2Fupdate-file-metadata-with-rest-api-using-validateupdatelistitem-method%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERobert's%20blog%3C%2FA%3E).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EBesides%20%3CA%20href%3D%22https%3A%2F%2Frobertschouten.com%2F2018%2F04%2F30%2Fupdate-file-metadata-with-rest-api-using-validateupdatelistitem-method%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERobert's%20blog%3C%2FA%3E%2C%20%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Fpulse%2Flist-items-system-update-options-sharepoint-online-andrew-koltyakov%2F%3Fsrc%3Daff-lilpar%26amp%3Bveh%3Daff_src.aff-lilpar_c.partners_pkw.10078_plc.Skimbit%2520Ltd._pcrid.449670_learning%26amp%3Btrk%3Daff_src.aff-lilpar_c.partners_pkw.10078_plc.Skimbit%2520Ltd._pcrid.449670_learning%26amp%3Bclickid%3D2133FhSjJxyJRNEwUx0Mo34lUkizG9V1py1kUg0%26amp%3Birgwc%3D1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAndrew%E2%80%99s%20blog%3C%2FA%3E%20also%20presented%20detailed%20info%20about%20how%20to%20set%20various%20types%20of%20fields%20with%20%3CEM%3EValidateUpdateListItem().%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3EMy%20issue%20was%20to%20update%20%3CSTRONG%3EEditor%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EAuthor%3C%2FSTRONG%3E%20fields%20for%20a%20listitem%20on%20SharePoint%20on-premises%20(SP2016%20and%20SP%202019)%20without%20increasing%20item%20version.%3C%2FP%3E%0A%3CP%3EBoth%20%3CSTRONG%3EEditor%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EAuthor%3C%2FSTRONG%3E%20are%20People%20and%20Group%20(Person)%20field.%20According%20above%20blogs%2C%20you%20can%20set%20the%20Person%20field%2C%20like%3A%3C%2FP%3E%0A%3CP%3E%22%5B%7B'Key'%3A%3CSTRONG%3E'%3C%2FSTRONG%3E%3CSTRONG%3Ei%3A0%23.f%7Cmembership%3C%2FSTRONG%3E%7Caaron%40%3CSPAN%3Econtoso.onmicrosoft.com%3C%2FSPAN%3E'%7D%5D%22%3C%2FP%3E%0A%3CP%3EThis%20works%20fine%20with%20SharePoint%20Online%20users.%20However%2C%20it%20does%20not%20work%20with%20SharePoint%20on-premises%20users%2C%20although%20no%20error%20returned%20from%20the%20method.%3C%2FP%3E%0A%3CP%3EAfter%20some%20testing%2C%20I%20found%20that%20for%20SharePoint%20on-premises%20users%2C%20you%20need%20to%20set%20the%20Persons%20field%20like%20below%3A%3C%2FP%3E%0A%3CP%3E%22%5B%7B'Key'%3A'%3CSTRONG%3Ei%3A0%23.w%3C%2FSTRONG%3E%7Caaron%40testdomain.com'%7D%5D%22%3C%2FP%3E%0A%3CP%3EThe%20sample%20below%20updates%20the%20%3CSTRONG%3EEditor%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EAuthor%3C%2FSTRONG%3E%20fields%20on%20SharePoint%20on-premises%20(SP2016%20and%20SP2019)%20without%20increasing%20item%20version.%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22formValues%22%3A%20%5B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22__metadata%22%3A%20%7B%20%22type%22%3A%20%22SP.ListItemFormUpdateValue%22%20%7D%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22FieldName%22%3A%20%22Editor%22%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22FieldValue%22%3A%20%22%5B%7B'Key'%3A'i%3A0%23.w%7Caaron%40testdomain.com'%7D%5D%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22__metadata%22%3A%20%7B%20%22type%22%3A%20%22SP.ListItemFormUpdateValue%22%20%7D%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22FieldName%22%3A%20%22Author%22%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22FieldValue%22%3A%20%22%5B%7B'Key'%3A'i%3A0%23.w%7Caaron%40testdomain.com'%7D%5D%22%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%5D%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22bNewDocumentUpdate%22%3A%20true%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20REST%20API%20%3CEM%3EValidateUpdateListItem()%3C%2FEM%3E%20on%20the%20ListItem%20object%20is%20much%20easier%20in%20providing%20the%20Person%20field%20values%20to%20update.%20In%20addition%2C%20it%20has%20an%20option%20bNewDocumentUpdate%20to%20specify%20how%20you%20want%20item%20version%20to%20be%20updated.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

This post is a contribution from Aaron Mio, an engineer with the SharePoint Developer Support team.

 

Lately. I came across an issue of using REST API ValidateUpdateListItem() to update listitem metadata. There’re a few blogs published on method ValidateUpdateListItem() for SharePoint Online. A few benefits of using ValidateUpdateListItem are:

  • Update list items without increasing its item version (see this blog for details).
  • Easier to update some types of metadata, like Taxonomy, People and Lookup fields (mentioned in Robert's blog).

Besides Robert's blog, Andrew’s blog also presented detailed info about how to set various types of fields with ValidateUpdateListItem().

My issue was to update Editor and Author fields for a listitem on SharePoint on-premises (SP2016 and SP 2019) without increasing item version.

Both Editor and Author are People and Group (Person) field. According above blogs, you can set the Person field, like:

"[{'Key':'i:0#.f|membership|aaron@contoso.onmicrosoft.com'}]"

This works fine with SharePoint Online users. However, it does not work with SharePoint on-premises users, although no error returned from the method.

After some testing, I found that for SharePoint on-premises users, you need to set the Persons field like below:

"[{'Key':'i:0#.w|aaron@testdomain.com'}]"

The sample below updates the Editor and Author fields on SharePoint on-premises (SP2016 and SP2019) without increasing item version.

{

      "formValues": [

            {

                  "__metadata": { "type": "SP.ListItemFormUpdateValue" },

                  "FieldName": "Editor",

                  "FieldValue": "[{'Key':'i:0#.w|aaron@testdomain.com'}]"

            },

            {

                  "__metadata": { "type": "SP.ListItemFormUpdateValue" },

                  "FieldName": "Author",

                  "FieldValue": "[{'Key':'i:0#.w|aaron@testdomain.com'}]"

            }

      ],

      "bNewDocumentUpdate": true

}

 

The REST API ValidateUpdateListItem() on the ListItem object is much easier in providing the Person field values to update. In addition, it has an option bNewDocumentUpdate to specify how you want item version to be updated.