2

I am using ReactJS to develop a custom form and my list includes a multiple lines of text field with the AppendOnly flag set to true. When I open the form, I want to retrieve the version history for the item with information about the Author/Editor of each version so I can present this information to the user. I am successfully retrieving the version history, but the response does not include the Author/Editor.

Environment: SharePoint 2016 on AWS GovCloud.

Request:

(await fetch("https://server.gov/site/path/_api/web/GetFileByServerRelativeUrl('/site/path/Lists/MyList/133_.000')/versions?$expand=Author,Editor&$select=Author/Title,Created,Editor/Title,Modified,AppendOnlyField", {
  "headers": {
    "accept": "application/json;odata=nometadata",
  },
  "method": "GET"
})).json().then((response) => (console.log(response)));

Response:

{
  value: [
    0: {
      "Created": "2020-09-10T21:02:30Z"
    }
  ]
}

Update

I'm able to get the user information now, but not what changes were made.

Request:

(await fetch("https://server.gov/site/path/_api/web/GetFileByServerRelativeUrl('/site/path/Lists/MyList/133_.000')/versions?$expand=CreatedBy&$select=*", {
  "headers": {
    "accept": "application/json;odata=verbose",
  },
  "method": "GET"
})).json().then((response) => (console.log(response)));

Response:

{
  "d": {
    "results": [
      // ...older versions
      {
        "__metadata": {...},
        "Created": "2020-09-10T21:02:30Z",
        "CreatedBy":
        {
          "__metadata": { ... },
          "Email": "----------@server.gov",
          "Groups": { __deferred: { ... } },
          "Id": 2403,
          "IsHiddenInUI": false,
          "IsShareByEmailGuestUser": false,
          "IsSiteAdmin": true,
          "LoginName": "i:0ǵ.t|adfs|----------",
          "PrincipalType": 1,
          "Title": "Rowe, Paul ---------",
          "UserId": { ... }
        },
        "Id": 31232,
        "IsCurrentVersion": false,
        "Length": "0",
        "Size": 0,
        "Url": "_vti_history/31232/Lists/MyList/133_.000",
        "VersionLabel": "61.0"
      }
    ]
  }
}

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.