Hello,
How do I get a Sharepoint Site URL when I have a Site Id using powershell&graphAPI? I'm using an app registration to autohorize.
This is a part of powershell script:
$CustomerGraphToken = New-PartnerAccessToken -ApplicationId $ApplicationId -Credential $credential -RefreshToken $refreshtoken -Scopes 'https://graph.microsoft.com/.default' -ServicePrincipal -Tenant $customer.TenantID
$Header = @{
Authorization = "Bearer $($CustomerGraphToken.AccessToken)"
}
$SharepointURI = "https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(period='D7')"
$spoResult = (Invoke-RestMethod -Headers $Header -Uri $SharepointURI -Method Get -ContentType "application/json; charset=utf-8") | ConvertFrom-Csv
This gives me a correct result. The problem is that almost every site's "Site URL" field are empty.
That result gives every site's "Site Id" though. So I believe I should be able to use "Site Id" to get an information about Sharepoint Site with a different Graph API URI.
I tried using this Graph API URI "https://graph.microsoft.com/v1.0/sites/{site-id}"
The app registration does has a permission of "Sites.Read.All, Sites.ReadWrite.All" (type Application), but I get an error "(401) Unautohrized".
What am I doing wrong and why some of Graph API URI's work and some say "Unauthorized" even though the permissions are correct?
Thanks.