Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b265980
SharePoint Graph API support
Drakonian May 7, 2025
a50eda6
Merge remote-tracking branch 'origin/main' into SharePointGraphAPISup…
Drakonian May 15, 2025
a876ce7
Move site & drive requests from initialization to lazy load upon spec…
Drakonian May 18, 2025
0219ec1
Ability to set http client handler
Drakonian Jun 3, 2025
c7d3570
Merge remote-tracking branch 'origin/main' into SharePointGraphAPISup…
Drakonian Jun 18, 2025
148ab23
Merge branch 'main' into SharePointGraphAPISupport
JesperSchulz Oct 29, 2025
abbd08e
Merge branch 'microsoft:main' into SharePointGraphAPISupport
Drakonian Nov 16, 2025
63510a4
Remove "var" from InStream in Upload operations
Drakonian Nov 16, 2025
d85ce42
Remove unused internal graph pagination procedures
Drakonian Nov 16, 2025
e0f0285
Restore GetAllPages procedure (deleted by mistake)
Drakonian Nov 26, 2025
1a33c07
Additional tests for Graph SharePoint module
Drakonian Dec 1, 2025
55bdc9a
remove duplicate method
Drakonian Dec 1, 2025
5c6eae2
Fix typo with OuStream.Write to CopyStream
Drakonian Dec 1, 2025
eb71ef1
Move sharepoint graph library objects to library app
Drakonian Dec 1, 2025
0a2461b
Move graph sharepoint test to graph folder
Drakonian Dec 1, 2025
edfc8c4
Remove manual subscription mode from prev redesign
Drakonian Dec 3, 2025
f2b00b5
Merge remote-tracking branch 'origin/main' into SharePointGraphAPISup…
Drakonian Dec 4, 2025
f20f340
Merge remote-tracking branch 'origin/main' into SharePointGraphAPISup…
Drakonian Dec 7, 2025
1993cec
Add missed Inherent permissions
Drakonian Dec 10, 2025
5651d47
Add SharePoint Graph Client examples to Readme of SharePoint module
Drakonian Dec 11, 2025
7414381
Format permissions for better readability
JesperSchulz Dec 19, 2025
9986499
Add missed Rest Client dependency
Drakonian Dec 19, 2025
322bc27
Sharepoint module should see internal from Microsoft Graph
Drakonian Jan 7, 2026
77d35c1
sort using directives
Drakonian Jan 8, 2026
058160f
add missing dependencied to SharePoint test applicaiton
Drakonian Jan 9, 2026
a3f5bea
Add missing dependencies to SharePoint test library application
Drakonian Jan 9, 2026
b360e06
Add missing dependency
Drakonian Jan 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/System Application/App/MicrosoftGraph/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
"id": "2746dab0-7900-449d-b154-20751e116a67",
"name": "Microsoft Graph Test",
"publisher": "Microsoft"
},
{
"id": "1a7bfa64-c856-49ed-86b0-bb05eb5b2de4",
"name": "SharePoint",
"publisher": "Microsoft"
}
],
"screenshots": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ enum 9353 "Graph Request Header"
{
Caption = 'ConsistencyLevel', Locked = true;
}

/// <summary>
/// Range Request Header
/// </summary>
value(40; Range)
{
Caption = 'Range', Locked = true;
}
}
164 changes: 157 additions & 7 deletions src/System Application/App/SharePoint/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,166 @@
Provides functions to interact with SharePoint REST API
Provides functions to interact with SharePoint.

Use this module to do the following:
> Navigate Lists and Folders.
Two clients are available:
- **SharePoint Client** - Legacy REST API v1
- **SharePoint Graph Client** - Modern Microsoft Graph API

> Upload and Download files.
---

> Create folders and list items.
# SharePoint Graph Client

Modern implementation using Microsoft Graph API. Provides simpler authentication, cleaner interfaces, and better performance.

# Authorization
## Authorization

Use Graph Authorization from the Graph module:

```al
var
GraphAuth: Codeunit "Graph Authorization";
GraphAuthorization: Interface "Graph Authorization";
begin
GraphAuthorization := GraphAuth.CreateAuthorizationWithClientCredentials(
'<MicrosoftEntraTenantId>', '<ClientId>', '<ClientSecret>',
'https://graph.microsoft.com/.default');
```

## Initialize Client

```al
var
SPGraphClient: Codeunit "SharePoint Graph Client";
begin
SPGraphClient.Initialize('https://contoso.sharepoint.com/sites/MySite/', GraphAuthorization);
```

## Working with Lists

```al
var
GraphList: Record "SharePoint Graph List" temporary;
Response: Codeunit "SharePoint Graph Response";
begin
// Get all lists
Response := SPGraphClient.GetLists(GraphList);

// Create a new list
Response := SPGraphClient.CreateList('My List', 'Description', GraphList);
```

## Working with List Items

```al
var
GraphListItem: Record "SharePoint Graph List Item" temporary;
begin
// Get items from a list
Response := SPGraphClient.GetListItems('<ListId>', GraphListItem);

// Create a new item
Response := SPGraphClient.CreateListItem('<ListId>', 'Item Title', GraphListItem);
```

## Working with Drives and Files

```al
var
GraphDriveItem: Record "SharePoint Graph Drive Item" temporary;
TempBlob: Codeunit "Temp Blob";
FileInStream: InStream;
Response: Codeunit "SharePoint Graph Response";
begin
// Get root folder items
Response := SPGraphClient.GetRootItems(GraphDriveItem);
if not Response.IsSuccessful() then
Error(Response.GetError());

// Filter to files only and download first one
GraphDriveItem.SetRange(IsFolder, false);
if GraphDriveItem.FindFirst() then
Response := SPGraphClient.DownloadFile(GraphDriveItem.Id, TempBlob);

// Get items by path
Response := SPGraphClient.GetItemsByPath('Documents/Folder1', GraphDriveItem);

// Upload a file (empty path = root folder)
Response := SPGraphClient.UploadFile('', 'file.pdf', FileInStream, GraphDriveItem);

// Create a folder
Response := SPGraphClient.CreateFolder('Documents', 'NewFolder', GraphDriveItem);
```

## Large File Operations

For files over 4MB, use chunked upload/download:

```al
begin
// Upload large file (uses resumable upload session)
Response := SPGraphClient.UploadLargeFile('Documents', 'largefile.zip', FileInStream, GraphDriveItem);

// Download large file (uses 100MB chunks)
Response := SPGraphClient.DownloadLargeFile('<ItemId>', TempBlob);
```

## Item Management

```al
var
Exists: Boolean;
Response: Codeunit "SharePoint Graph Response";
begin
// Check if item exists
Response := SPGraphClient.ItemExistsByPath('Documents/file.pdf', Exists);

// Delete item
Response := SPGraphClient.DeleteItemByPath('Documents/file.pdf');

// Copy item (asynchronous operation)
Response := SPGraphClient.CopyItemByPath('Documents/file.pdf', 'Archive', 'file_copy.pdf');

// Move/rename item
Response := SPGraphClient.MoveItemByPath('Documents/file.pdf', 'Archive', '');
```

## OData Query Parameters

```al
var
OptionalParams: Codeunit "Graph Optional Parameters";
begin
// Filter items
SPGraphClient.SetODataFilter(OptionalParams, 'name eq ''document.docx''');

// Select specific fields
SPGraphClient.SetODataSelect(OptionalParams, 'id,name,size');

// Order results
SPGraphClient.SetODataOrderBy(OptionalParams, 'name asc');

Response := SPGraphClient.GetRootItems(GraphDriveItem, OptionalParams);
```

## Error Handling

All methods return `SharePoint Graph Response` codeunit:

```al
var
Response: Codeunit "SharePoint Graph Response";
begin
Response := SPGraphClient.GetLists(GraphList);
if not Response.IsSuccessful() then
Error(Response.GetError());
```

---

# SharePoint Client (Legacy REST API)

Legacy implementation using SharePoint REST API v1.

## Authorization

## User Credentials
Use "SharePoint Authorization module".

## Example
Expand Down
12 changes: 12 additions & 0 deletions src/System Application/App/SharePoint/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@
"name": "BLOB Storage",
"publisher": "Microsoft",
"version": "28.0.0.0"
},
{
"id": "6d72c93d-164a-494c-8d65-24d7f41d7b61",
"name": "Microsoft Graph",
"publisher": "Microsoft",
"version": "28.0.0.0"
},
{
"id": "812b339d-a9db-4a6e-84e4-fe35cbef0c44",
"name": "Rest Client",
"publisher": "Microsoft",
"version": "28.0.0.0"
}
],
"screenshots": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ permissionset 9100 "SharePoint API - Objects"
Access = Internal;
Assignable = false;

Permissions = codeunit "SharePoint Client" = X;
Permissions = codeunit "SharePoint Client" = X,
codeunit "SharePoint Graph Client" = X;
}
Loading