好吧,所以在與微軟「專業支持」聊天后,他們無法幫助我。告訴我通過SfB報告GUI訪問報告並導出到Excel。錯誤400錯誤的請求,當試圖通過圖表API的Skype的商業活動
是的,這對我來說完全沒有價值。 在做了更多的閱讀之後,我的第一個認證過程已過時。
現在我有一個功能齊全的oAuth2 PowerShell腳本,它爲我提供了一個有效的令牌。
但是我在使用Graph Explorer(403 Forbidden)時遇到同樣的問題。 我知道令牌正在工作,因爲我可以查詢其他信息\如果我從GET頭中拿走令牌的VAR,它會顯示承載令牌爲空,因此一切正常。
Microsoft, if you're out there can someone please confirm that the SfB Report API is up and running for the statistics I'm attempting to pull?
更新後的腳本
#Obtaining oAuth2 Token from Microsoft Azure \ communicate with Microsoft Graph API
$ClientID = "MyID"
$client_Secret = "MySecretKey"
#Define URI for Azure Tenant
$Uri = "https://login.microsoftonline.com/MyTenantID/oauth2/token"
#Define Microsoft Graph - Skype for Business reports interface URI
$exportSfB = "https://graph.microsoft.com/beta/reports/SfbActivity(view='Detail',date='2017-04-11')/content"
#Define the body of the request
$Body = @{grant_type='client_credentials';client_id=$ClientID;client_secret=$client_secret;resource='https://graph.microsoft.com'}
#Define the content type for the request
$ContentType = "application/x-www-form-urlencoded"
#Invoke REST method. This handles the deserialization of the JSON result. Less effort than invoke-webrequest
$admAuth=Invoke-RestMethod -Uri $Uri -Body $Body -Method Post
#Construct the header value with the access_token just recieved
$HeaderValue = "Bearer " + $admauth.access_token
#Query Microsoft Graph with new Token
$result = Invoke-RestMethod -Headers @{Authorization=$HeaderValue} -Uri $exportSfB –Method Get -Verbose
#Results should be a .CSV
$result.string.'#text'
原來的線程 可有人請看看這個REST代碼,並告訴我,他們怎麼想?
我收到:
調用-RestMethod:遠程服務器返回錯誤:(400)錯誤的請求。
- CategoryInfo:InvalidOperation
我一直沒能拉一個Skype的使用圖形業務活動的報告。
$tenant = "MyTenant.onmicrosoft.com"
function GetAuthToken
{
param
(
[Parameter(Mandatory=$true)]
$TenantName
)
$adal = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.dll"
$adalforms = "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Services\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
[System.Reflection.Assembly]::LoadFrom($adal) | Out-Null
[System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null
$clientId = "MyID"
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
$resourceAppIdURI = "https://graph.microsoft.com/"
$authority = "https://login.windows.net/$TenantName"
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId,$redirectUri, "Auto")
return $authResult
}
# Set Token var
$token = GetAuthToken -TenantName $tenant
# Building Rest Api header with authorization token
$authHeader = @{
'Content-Type'='application\json'
'Authorization'=$token.CreateAuthorizationHeader()
}
$uri = "https://graph.microsoft.com/beta/reports/SfbActivity(view='Detail',date='2017-04-11')"
$output = (Invoke-RestMethod -Uri $uri –Headers $authHeader –Method Get –Verbose).value
不幸的是,雖然這並不能解決問題。我無法使用Microsoft Graph Explorer進行工作。我有一張向微軟開放的門票。我意識到它在Beta中,但我真的需要讓這些統計數據下降。 – CWB
無論目前如何,Graph Explorer可能無法正常工作。我不相信它會請求Reports.Read.All作用域,所以它只會回滾403錯誤。 –
嗨馬克,你知道如果SfB API的報告是可訪問的? – CWB