Forum Discussion
GSYSJobs
Jul 06, 2023Copper Contributor
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...
- Jul 10, 2023Solved!
 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
GSYSJobs
Jul 10, 2023Copper Contributor
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
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