- User Manuals /
- Virtual DataPort Administration Guide /
- Creating Data Sources and Base Views /
- Software as a Service Wizards /
- SharePoint REST API
SharePoint REST API¶
SharePoint includes a REST service that is comparable to the existing SharePoint client object models. Now, it is possible to interact directly with SharePoint objects by using any technology that supports standard REST capabilities.
Getting OAuth 2.0 Credentials¶
To get the OAuth credentials to configure the SharePoint REST API wizard, click Tools > OAuth credential wizards > OAuth 2.0 wizard.
The Tool will display the dialog to get the OAuth tokens.
To get the OAuth tokens, enter the following parameters:
Client identifier. The client id from the newly created Azure application.
Client secret. The value of the secret generated in the previous step for the newly created application.
Token endpoint URL. https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token.
Authorization server URL. https://login.microsoftonline.com/common/oauth2/v2.0/authorize.
Redirect URI. The redirect URI used when registering the app in Azure.
Scopes. Enter this:
offline_access
https:/<tenant_name>.sharepoint.com/AllSites.Read
These scopes are necessary to have the necessary privileges to query your data.
After providing all the values, click Generate Authorization URL and, when the Authorization URL is generated, click open URL link. This opens a window in your browser and in the page, provide the permission, and once the permission is given a URL with code would be generated. The format of the URL will be: https://<tenant_name>.sharepoint.com/?code=<>&state=<>&session_state=<>#
Paste the same on the Paste the authorized response URL and select Obtain the OAuth 2.0 credentials.
Finally, click on Copy the credentials to the clipboard to save the OAuth tokens.
Importing Artifacts¶
Now, you have all the data needed to use the SharePoint wizard. Click the menu File > New > Data source and select Microsoft SharePoint REST API.
Enter the following parameters:
Database. Name of the database in which the SharePoint data sources and views will be created.
View name prefix. The name prefix of every view created in order to be able to relate VDP views to SharePoint Online sites. The max length of this parameter is 10 characters.
SharePoint Online service name . The access token generated in the VDP wizard for OAuth 2.0.
Realm. The directory tenant id.
Client ID. The client id generated when registering the Azure app.
Client Secret. The client secret generated when registering the Azure app.
Redirect URI. The redirect URI registered when creating the Azure app.
Access token . The access token generated in the previous step.
Refresh token . The refresh token generated in the previous step.
Site name. The site name of the specific SharePoint Online site you want to retrieve list and folders content.
Now, click Execute import to create the data sources and the views to query SharePoint.
Note
The views created are read-only.
Note
We have used site2 as the value of the View name prefix configuration parameter in the examples shown below.
${view.prefix}_all_lists. Retrieving all the lists of the SharePoint site specified in the Site name property.
${view.prefix}_file. Retrieving a file.
Required parameters:
file_path
: The path to the file.
${view.prefix}_file_list_item_all_fields. Retrieving the value of the
ListItemAllFields
property of the file.Required parameters:
file_path
: path to the file.
${view.prefix}_file_modified_by. Retrieving the value of the ModifiedBy property of the file.
Required parameters:
file_path
: path to the file.
bv_${view.prefix}_file_version_events. Retrieving the value of the VersionEvents property of the file.
Required parameters:
file_path
: path to the file.
bv_${view.prefix}_file_versions. Retrieving the value of the Version property of the file.
Required parameters:
file_path
: path to the file.
bv_${view.prefix}_files_attached_to_list. Retrieving all the files that are attached to a list item.
Required parameters:
list_name
: the name of the list.item_id
: the id of the item.
${view.prefix}_files_in_folder. Retrieving the files in a folder.
Required parameters:
folder_path
: the path of the folder.
${view.prefix}_folder. Retrieving info about the folder.
Required parameters:
folder_path
: the path to the folder.
${view.prefix}_folder_parent. Retrieving the value of the ParentFolder property of the folder.
Required parameters:
folder_path
: the path to the folder.property_name
: the name of the property.
bv_${view.prefix}_items_by_list_name. Retrieving all items in a list.
Required parameters:
list_name
: the name of the list.
bv_${view.prefix}_list_as_stream. Retrieving items as a stream.
Required parameters:
list_name
: the name of the list
${view.prefix}_list_by_guid. Retrieving the details of a list by GUID.
Required parameters:
guid
: The list guid.
${view.prefix}_list_by_name: Retrieve a list by name.
Required parameters:
list_name
: the name of the list
${view.prefix}_subfolders_in_folder. Retrieving the folders in a folder.
Required parameters:
folder_path
: the path to the folder.
${view.prefix}_web. Retrieving the details of the site specified in the Site name property.
bv_${view.prefix}_web_title. Retrieving the title of the site specified in the Site name property.
bv_${view.prefix}_excel_file. Retrieving an excel file.
Required parameters:
file_path
: the path of the file to retrieve.
${view.prefix}_folder_full_content. Retrieving both the files and the folders of the folder.
Required parameters:
folder_path
: the path of the folder.
Note
All paths are relative to /sites/${sharepoint.site.name}/.
Query Example¶
Now, you can execute queries on the SharePoint Online views that have been created:
Query 1. Retrieving all the content of the folder
MyLibrary
.Query 2. Retrieving the files attached to the item 2 attached to
MyList
list.Query 3. Retrieving an excel file.