3

I am trying to get the 'Editor/Name' using REST however this does not appear to be working.

My current REST url is formed as follows:

https://tenant.sharepoint.com/sites/sitecollection/_api/web/GetFileByServerRelativeUrl('/sites/sitecollection/Documents/MyDocument.pptx')?$select=Title,InternalName,Editor/Title&$expand=Editor

This currently just returns the Title however I want to return the 'Editor' name. I have tried multiple instances of this including expanding 'Editor/Id' however to no avail.

Can anyone advise on why this is not working please.

Thanks!

3

You need to adjust the endpoint a bit. Need to specify ListItemAllFields,ModifiedBy as expand param and also specify Title,ModifiedBy,ListItemAllFields/InternalName as select values.

Replace the internal name with the actual name of the column in your SP Doc lib.

Modify the endpoint as below:

/_api/web/GetFileByServerRelativeUrl('/sites/sitecollection/Documents/MyDocument.pptx')?
$select=Title,ModifiedBy,ListItemAllFields/InternalName&$expand=ListItemAllFields,ModifiedBy
  • Hi Guatam, sorry for the late reply. I have just had the chance to come back to this. Unfortunately this does not work for me, what I should have expanded on within my ticket is that when using ModifiedBy I get the error: "User cannot be found" – Adam13Hylo May 28 at 16:32
2

Answer that was provided by Gautam Sheth is great!

As alternative you can use endpoint - /_api/web/lists/getbytitle

If you know ID of listitem\document try:

https://tenant.sharepoint.com/sites/sitecollection/_api/web/lists/getbytitle('Documents')/items(1)?$select=Title,InternalName,Editor/Title&$expand=Editor/Id

Where 1 is document Id.

Your Answer

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

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