0

So I have been using the ValidateUpdateListItem endpoint to set the created and modified dates with no problems in both 2013/2019 and Online and now need to do the same for Author/Editor fields.

I have read around and found that when setting this via ValidateUpdateListItem we should set the FieldValue to [{'Key':'i:0#.w|domain\username'}] - that value is retrieved from the LoginName property returned from an ensure user call (_api/web/ensureuser). For online this would be an email address rather than domain\username.

This results in the body of my post to _api/web/getfilebyserverrelativeurl('some-server-relative-url')/listitemallfields/ValidateUpdateListItem() looking like:

{
  "formValues":
  [
    {
      "__metadata":{"type":"SP.ListItemFormUpdateValue"},
      "FieldName":"Author",
      "FieldValue":"[{'Key':'i:0#.w|domain\username'}]"
    },
    {
      "__metadata":{"type":"SP.ListItemFormUpdateValue"},
      "FieldName":"Editor",
      "FieldValue":"[{'Key':'i:0#.w|domain\username'}]"
    }
  ],
  "bNewDocumentUpdate":true,
  "checkInComment":"Some Comment"
}

No errors are listed on the return collection of this call, but no updates are made in SharePoint itself.

So question is - should something be different when targeting online versus on premise? For example is the format of what is provided to FieldValue any different?

Once again, the same call works with SharePoint online (albeit the user info is slightly different: i:0#.f|membership|[email protected]) but fails on SP2013 and 2019.

Finally, I have tried against the same on premise instances with the same user using CSOM and it is able to set those fields... we would rather not have to fall back to CSOM here given the frequent nature of the calls.

Thanks in advance

2
  • Was this ever resolved ? I can update a person column but not Created By (Author) Mar 8, 2023 at 11:59
  • No, as we had a need to use CSOM elsewhere we ended up falling back to that
    – A.W.
    Jul 5, 2023 at 8:05

2 Answers 2

0

In the string "i:0#.f|membership|[email protected]", try to remove 'membership' and replace 'f' with 'w'.

It should look like 'i:0#.w|[email protected]'.

https://techcommunity.microsoft.com/t5/microsoft-sharepoint-blog/update-file-metadata-with-rest-api-using-validateupdatelistitem/ba-p/1365682

0

Note that you need FullControl permissions, at least in SharePoint online. Write and Manage permission are not sufficient. With only Write or Manage permission, the structured returned by validateUpdateListItem() will indicate that Editor and Modified were written successfully, but they will not change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.