Forum Discussion

Gabriel Smoljar's avatar
Gabriel Smoljar
Brass Contributor
Mar 27, 2023

Get direct link to file from RenderListDataAsStream API

I am refactoring old code from using Microsoft.SharePoint.Client.List.GetListItems to RenderListDataAsStream as it seems to support large lists better.

 

One problem is that I currently get the LinkingUri from ListItem.File.LinkingUri. This is the same link as you would get from sharing with "people with existing access" from the modern UI. I am unable to find a way to include this in the response from RenderListDataAsStream, as getting it in a separate request for each file would be expensive.

Example url: https://contoso.sharepoint.com/sites/teamsite/Shared%20Documents/foobar.xlsx?d=w258e6a73e2574e9ca3a81ab9555d01e9&csf=1&web=1&e=LDfMkk

  • Gabriel Smoljar 

     

    Is there any specific reason for getting this link? do you want to hide actual file name in the link? otherwise you could also add "?web=1" in the absolute URL at the end which can open supported document in browser by default.

     


    Hope it will helpful to you and if so then Please mark my response as Best Response & Like to help others in this community

    • Gabriel Smoljar's avatar
      Gabriel Smoljar
      Brass Contributor
      Sorry for the late reply. The nice thing about that link is that it is persistent, even if the file moves to a different folder. Luckily I realized that the value of the query string parameters was just same as the GUID column value, without dashes. So it was easy to recreate in my own code 🙂