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|someemail@test.com) 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.