
Add Sharepoint
Provision or extend SharePoint lists and columns via Microsoft Graph using Azure CLI tokens when wiring Power Platform or internal line-of-business data stores.
Install
npx skills add https://github.com/microsoft/power-platform-skills --skill add-sharepointWhat is this skill?
- Microsoft Graph v1.0 with Bearer tokens from az account get-access-token --resource https://graph.microsoft.com
- PowerShell helpers: Get-SiteId from tenant SharePoint URLs, standardized JSON headers
- Documents Authorization, Content-Type, and optional Prefer HonorNonIndexedQueriesWarningMayFailRandomly header
- Prerequisite flow: az account show / az login before any Graph mutations
- Site URL pattern https://{tenant}.sharepoint.com/sites/{site-name} parsed to hostname and server-relative path
Adoption & trust: 107 installs on skills.sh; 349 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Journey fit
SharePoint list schema work is third-party Microsoft cloud integration during product build, not audience research or growth analytics. Graph API calls for sites, lists, and columns are backend/integration tasks against tenant SharePoint, distinct from Studio UI or mobile ASO.
Common Questions / FAQ
Is Add Sharepoint safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Add Sharepoint
# API Authentication Reference Uses Microsoft Graph API with Azure CLI authentication (`az account get-access-token`) to manage SharePoint lists and columns. ## Prerequisites Ensure Azure CLI is authenticated before proceeding: ```powershell # Verify Azure CLI is logged in az account show # If not logged in, run: az login ``` ## Get Access Token ```powershell $token = (az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv) ``` ## Set Up API Headers ```powershell $headers = @{ "Authorization" = "Bearer $token" "Content-Type" = "application/json" } ``` ## API Headers Reference | Header | Value | Purpose | |--------|-------|---------| | `Authorization` | `Bearer <token>` | Authentication token | | `Content-Type` | `application/json` | Request body format | | `Prefer` | `HonorNonIndexedQueriesWarningMayFailRandomly` | Allow non-indexed queries (optional) | ## Get Site ID from URL SharePoint site URLs follow the pattern `https://{tenant}.sharepoint.com/sites/{site-name}`. Extract the site ID using the Graph API: ```powershell function Get-SiteId { param( [Parameter(Mandatory=$true)] [string]$SiteUrl, [Parameter(Mandatory=$true)] [hashtable]$Headers ) # Parse the URL into hostname and server-relative path $uri = [System.Uri]$SiteUrl $hostname = $uri.Host $serverRelativePath = $uri.AbsolutePath.TrimEnd('/') $graphUrl = "https://graph.microsoft.com/v1.0/sites/${hostname}:${serverRelativePath}" $site = Invoke-RestMethod -Uri $graphUrl -Headers $Headers return $site.id } ``` ## Complete Setup Script ```powershell function Initialize-SharePointGraphApi { param( [Parameter(Mandatory=$true)] [string]$SiteUrl ) $token = (az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv) if (-not $token) { throw "Failed to get access token. Make sure you're logged in with 'az login'" } $headers = @{ "Authorization" = "Bearer $token" "Content-Type" = "application/json" } $siteId = Get-SiteId -SiteUrl $SiteUrl -Headers $headers Write-Host "Connected to site: $SiteUrl" -ForegroundColor Green Write-Host "Site ID: $siteId" -ForegroundColor Cyan return @{ Headers = $headers SiteId = $siteId SiteUrl = $SiteUrl } } ``` ## Token Refresh Access tokens expire after ~1 hour. For long-running scripts: ```powershell function Get-FreshToken { return (az account get-access-token --resource https://graph.microsoft.com --query accessToken -o tsv) } function Invoke-GraphApi { param( [string]$Uri, [string]$Method = "Get", [hashtable]$Headers, [string]$Body = $null ) try { if ($Body) { return Invoke-RestMethod -Uri $Uri -Method $Method -Headers $Headers -Body $Body } else { return Invoke-RestMethod -Uri $Uri -Method $Method -Headers $Headers } } catch { if ($_.Exception.Response.StatusCode -eq 401) { Write-Host "Token expired, refreshing..." -ForegroundColor Yellow $newToken = Get-FreshToken $Headers["Authorization"] = "Bearer $newToken" if ($Body) { return Invoke-RestMethod -Uri $Uri -Method $Method -Headers $Headers -Body $Body } else { return Invoke-RestMethod -Uri $Uri -Method $Method -Headers $Headers } } throw } } ``` ## Verify Connection ```powershell try { $site = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/sites/$siteId" -Headers $headers Write-Host "Connected to: $($site.displayName)" -ForegroundColor Green Write-Host "Web URL: $($site.webUrl)" -ForegroundColor Cyan } catch { Write-Host "Connection failed: $($_.Exception.Message)" -ForegroundColor Red } ``` ## Required Permissions To create lists and manage col