How can we help you today?

How to Connect to a Specific Folder Inside a Document Library Using REST API

This article demonstrates how to use the REST API connection to display files from a specific folder in a Document Library.


For this guide, we want to showcase files inside this PDF Guides folder:


folder


This is the result:


result


TABLE OF CONTENTS


Prerequisites


sample document library


Step-by-step Tutorial

Follow the steps below to get started:


Step 1: Edit the ShortPoint Web Part

Go to the SharePoint page you want to use and click Edit:


Edit


Close the Toolbox:


close icon


Click the Edit properties icon:


Edit properties icon


Step 2: Switch to Grid Mode


NOTEShortPoint Connect is currently only available in Grid Mode.

Click the Switch to Grid Mode icon:


Switch to Grid Mode icon


Step 3: Copy and Prepare the REST API URL


NOTEBefore proceeding, you must already have an existing Document Library with folders and files. To learn how to create a Document Library, check out Create a Document Library in SharePoint.

sample document library

Copy the REST API URL:


https://site url/_api/web/GetFolderByServerRelativeUrl('Document Library Name/Target Folder Name')/Files


Substitute the items highlighted in red with your actual website URL, Document Library name, and the name of the folder you want to connect to. Here is an example of what the URL could look like:


https://yoursite.sharepoint.com/sites/marketingmaterials/_api/web/GetFolderByServerRelativeUrl('Guide/PDF Guides')/Files


Note: You can select specific fields/columns by adding the ?$select= query string to the end of your REST API URL and including the internal names of the columns.

For custom columns you created, you can use ListItemAllFields/CustomColumnInternalName

Here is an example REST API URL showing some default columns, as well as a custom column called "Description":

https://mycompany.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('Shared Documents/Folder Name')/Files?$select=Name,TimeCreated,TimeLastModified,Title, ListItemAllFields/Description,Author/Title&$expand=Author,ListItemAllFields

Check our our solution article ShortPoint REST API: Selecting, Filtering, Sorting Results in a SharePoint List to learn more.

Step 4: Edit the File List Design Element

NOTEBefore proceeding, make sure you already have the File List Design Element on your page: 

file list design element


Hover over the File List and select the cogwheel icon:


Cogwheel icon


Step 5: Paste the REST API URL and Connect

Switch to the Connect tab:


Connect tab


Select REST API:


REST API


Paste the REST API URL you prepared in Step 3 in the field provided:


paste


Click Connect:


connect


Step 6: Map Items

Switch to the Items tab:


Items tab


Delete all default content:


delete default content


Use the link icon to map what will be displayed as the Title, Subtitle, and Description. In our example, we will showcase the file name as the title, the date created as the subtitle, and leave the description blank:


map items


NOTEYou can customize what information appears in the Title, Subtitle, and Description fields. Feel free to use our example or choose your own preferred display options.

Set  #ServerRelativeUrl as the Link:


set link


NOTEYou can also set how the file icons will look. Simply go to the Advanced tab, navigate to the File Icon Styles section, and choose how you want it to be displayed:
 icon

Step 7: Preview and Save

Once satisfied, click Update:


Update


Click the eye icon to see your page in real-time:


eye icon


Click Save to apply all your changes:


Save


That’s it! You can now connect to a specific folder and showcase all its files.


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 33 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more