Appearance
SharePointService
Upload, list, and download files from SharePoint document libraries using the Microsoft Graph API.
Credentials
Uses the Entra ID app registration (tenant_id, client_id, client_secret).
Collect site_hostname, site_path, drive_name, and drive_id from your SharePoint site / document library (Graph or SharePoint admin). Typical Graph permissions: Sites.ReadWrite.All, Files.ReadWrite.All.
Usage
python
from elsai_cloud.sharepoint import SharePointService
sharepoint_service = SharePointService(
tenant_id="your_tenant_id",
client_id="your_client_id",
client_secret="your_client_secret",
site_hostname="your_site_hostname",
site_path="your_site_path",
drive_name="your_drive_name",
drive_id="your_drive_id",
)Constructor parameters:
| Parameter | Required | Description |
|---|---|---|
tenant_id | Yes | Azure AD tenant ID |
client_id | Yes | Azure AD app client ID |
client_secret | Yes | Azure AD app client secret |
site_hostname | Yes | SharePoint site hostname (e.g. yourorg.sharepoint.com) |
site_path | Yes | SharePoint site path (e.g. /sites/MyTeam) |
drive_name | Yes | Document library name |
drive_id | Yes | Document library drive ID |
Upload a file:
python
sharepoint_service.upload_file_to_sharepoint(
file_path="path/to/your/file.txt",
target_folder="Documents/FolderName",
)List files in a folder:
python
files = sharepoint_service.retrieve_sharepoint_files_from_folder(
folder_name="folderName",
)Download a file:
python
sharepoint_service.download_file_from_sharepoint(
file_id="your_file_id",
target_folder="path/to/download/folder",
)