좋아요, Microsoft "Professional Support"와 채팅 한 후 그들은 나를 도울 수 없었습니다. SfB Report GUI를 통해 보고서에 액세스하고 Excel로 내보낼 수 있다고 알려 주셨습니다.그래프 API를 통해 Skype for Business 활동을 끌어 오려고 할 때 오류 400 잘못된 요청
네, 그건 완전히 쓸모가 없습니다. 더 많은 독서를 한 후에, 나의 첫 번째 예는 인증이 오래되었습니다.
이제는 유효한 토큰을 얻는 완전한 기능을 갖춘 oAuth2 PowerShell 스크립트가 있습니다.
그러나 Graph Explorer (403 Forbidden)를 사용할 때 같은 문제가 발생합니다. GET 헤더에서 토큰에 대한 VAR을 제거하면 베어러 토큰이 비어있어 모든 것이 옳다는 오류가 표시되므로 다른 정보를 쿼리 할 수 있기 때문에 토큰이 작동하고 있음을 알고 있습니다. SCRIPT 업데이트]
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'
ORIGINAL THREAD 사람이 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를 사용하여 작동시키지 못했습니다. 나는 그것에 대해 마이크로 소프트에게 열리는 티켓을 가지고있다. 내가 베타에 있다는 것을 알았지 만 그 통계를 끌어 내야 할 필요가 있습니다. – CWB
현재 그래프 탐색기가 작동하지 않을 수 있습니다. 나는 그것이 Reports.Read.All 범위를 요청할 것이라고 믿지 않기 때문에 단지 403 오류를 다시 걷어 찰 것이다. –
안녕하세요. Marc,보고 용 SfB API에 액세스 할 수 있는지 확인해주세요. – CWB