I'm trying to alter a SharePoint Online file's 'Author'
and 'Editor'
through the REST API. I have first made sure to set the list fields 'Created By'
and 'Modified By'
property ReadOnlyField = false
. I'm trying any REST API I can get my hands on:
Sharepoint 2013 REST API
url: http://site/_api/web/Lists(guid'...')/items(3)
method: POST
headers:
Authorization: "Bearer " + accessToken
"IF-MATCH": "*"
"X-HTTP-Method":"MERGE",
content-type: "application/json;odata=verbose"
body: {"__metadata": {"type": "SP.Data.DocumentsItem"}, "EditorId": 21}
Error
status code: 409
body:
{
"odata.error" : {
"code" : "-2130575305, Microsoft.SharePoint.SPException",
"message" : {
"lang" : "en-US",
"value" : "The file <filename> has been modified by <username> on <timestamp>."
}
}
This error basically says "I can't set the editor to the value you give me because the editor is this user", where this user points to the previous editor
Sharepoint 2010 REST API
url: http://site/_vti_bin/listdata.svc/Documents(3)
method: POST
headers:
Authorization: "Bearer " + accessToken
"IF-MATCH": "*"
"X-HTTP-Method":"MERGE",
content-type: "application/json;odata=verbose"
body: {"ModifiedById": 21}
Error
status code: 500
body:
{
"error" : {
"code" : "",
"message" : {
"lang" : "en-US",
"value" : "An error occurred while processing this request."
}
}
}
Office 365 Files API
url: http://site/_api/v1.0/me/files/<file-id>
method: PATCH
headers:
Authorization: "Bearer " + accessToken
content-type: "application/json;odata=verbose"
body: {'lastModifiedBy': {'user': {'id': '<user uuid>'}}}
Error
status code: 400
body:
{
"error" : {
"code" : "-1, Microsoft.OData.Core.ODataException",
"message" : "Parsing JSON Light feeds or entries in requests without entity set is not supported. Pass in the entity set as a parameter to ODataMessageReader.CreateODataEntryReader or ODataMessageReader.CreateODataFeedReader method."
}
}
None of the responses make sense to me. Anyone had any luck with this?
If modifying these fields for already existing files is not possible, I would also be interested in being able to set these fields for new files being uploaded.