Forum Discussion

GSYSJobs's avatar
GSYSJobs
Copper Contributor
Jul 06, 2023
Solved

Get the preview URL in SharePoint Document library via REST API

I am making a custom web part that connects to the Documents list on SharePoint via Fetch. This is the call that I use for retrieving information:   /_api/web/lists/getByTitle('Documents')/items?$s...
  • GSYSJobs's avatar
    Jul 10, 2023
    Solved!
    Using the next URL we can retrieve the value "FileRef"
    /_api/web/lists/getbytitle('Documents')/items?$select=*,FileLeafRef,FileRef
    With these what I've made is

    https://contoso.sharepoint.com/sites/<<Name of your Site>>/Shared%20Documents/Forms/AllItems.aspx?id="+encodeURIComponent(file.FileRef.trim())+"&parent=/sites/<<fileName>>/Shared%20Documents

Resources