Describe the bug
Working with Microsoft support to obtain P2P VOIP call records sessions from https://graph.microsoft.com/beta/communications/callRecords/$callId/sessions returns empty values. In weeks long efforts, Microsoft support recommended posting the issue here.
Expected behavior
I reached out to Microsoft support in an effort to list all P2P (not PSTN) call records from our tenant's Teams environment. We needed the information to show the Teams callee and the Teams caller. The script using Graph, would never return results, and Microsoft gave up, requesting a post here.
How to reproduce
================================
CONFIGURATION
================================
$clientId = "YOUR_CLIENT_ID"
$tenantId = "YOUR_TENANT_ID"
$clientSecret = "YOUR_CLIENT_SECRET"
$outputFile = "C:\temp\Teams_P2P_Call_Report.csv"
$startDate = (Get-Date).AddDays(-10).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
================================
AUTHENTICATION
================================
$body = @{
client_id = $clientId
scope = "https://graph.microsoft.com/.default"
client_secret = $clientSecret
grant_type = "client_credentials"
}
$tokenResponse = Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
-Body $body
$headers = @{
Authorization = "Bearer $($tokenResponse.access_token)"
}
Write-Host "Authentication successful." -ForegroundColor Green
================================
INITIAL QUERY
================================
$uri = "https://graph.microsoft.com/beta/communications/callRecords?`$filter=startDateTime ge $startDate"
$results = @()
================================
LOOP THROUGH CALL RECORDS
================================
do {
Write-Host "Querying call records..." -ForegroundColor Yellow
$response = Invoke-RestMethod -Headers $headers -Uri $uri -Method GET
foreach ($call in $response.value) {
# Only peer-to-peer calls
if ($call.type -ne "peerToPeer") { continue }
$callId = $call.id
$startTime = $call.startDateTime
$endTime = $call.endDateTime
$duration = 0
if ($startTime -and $endTime) {
$duration = ([datetime]$endTime - [datetime]$startTime).TotalSeconds
}
# ================================
# GET SESSIONS (CRITICAL FIX)
# ================================
$sessionUri = "https://graph.microsoft.com/beta/communications/callRecords/$callId/sessions"
$sessions = Invoke-RestMethod -Headers $headers -Uri $sessionUri -Method GET
foreach ($session in $sessions.value) {
foreach ($segment in $session.segments) {
$caller = $segment.caller.identity.user
$callee = $segment.callee.identity.user
# Ensure both are Teams users (exclude PSTN)
if (-not $caller.userPrincipalName -or -not $callee.userPrincipalName) {
continue
}
$results += [PSCustomObject]@{
CallId = $callId
StartTime = $startTime
EndTime = $endTime
DurationSeconds = [int]$duration
CallerDisplayName = $caller.displayName
CallerUPN = $caller.userPrincipalName
CallerId = $caller.id
CalleeDisplayName = $callee.displayName
CalleeUPN = $callee.userPrincipalName
CalleeId = $callee.id
CallType = $call.type
}
Write-Host ("Captured: {0} -> {1}" -f $caller.userPrincipalName, $callee.userPrincipalName) -ForegroundColor Cyan
}
}
}
# Pagination
$uri = $response.'@odata.nextLink'
} while ($uri)
================================
EXPORT RESULTS
================================
$results | Export-Csv -Path $outputFile -NoTypeInformation -Encoding UTF8
Write-Host "Report exported to $outputFile" -ForegroundColor Green
SDK Version
2.36.1
Latest version known to work for scenario above?
No response
Known Workarounds
none
Debug output
VERBOSE: GET https://graph.microsoft.com/beta/communications/callRecords/cfd81849-a74d-4d76-8391-bbc7b4cb351c/sessions with
0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Comp
atible=false;charset=utf-8
VERBOSE: GET https://graph.microsoft.com/beta/communications/callRecords/d3ee3eac-1e09-44fa-aec6-0230b4e5e6a0/sessions with
0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Comp
atible=false;charset=utf-8
VERBOSE: GET https://graph.microsoft.com/beta/communications/callRecords/d69f985a-ee03-4074-a658-8a31d820a4f7/sessions with
0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Comp
atible=false;charset=utf-8
Configuration
- os: Windows Server 2019 - version 1809
- architecture: x64
Name Value
PSVersion 5.1.17763.8276
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.8276
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Other information
I do not know why the data is not returned.
Describe the bug
Working with Microsoft support to obtain P2P VOIP call records sessions from https://graph.microsoft.com/beta/communications/callRecords/$callId/sessions returns empty values. In weeks long efforts, Microsoft support recommended posting the issue here.
Expected behavior
I reached out to Microsoft support in an effort to list all P2P (not PSTN) call records from our tenant's Teams environment. We needed the information to show the Teams callee and the Teams caller. The script using Graph, would never return results, and Microsoft gave up, requesting a post here.
How to reproduce
================================
CONFIGURATION
================================
$clientId = "YOUR_CLIENT_ID"
$tenantId = "YOUR_TENANT_ID"
$clientSecret = "YOUR_CLIENT_SECRET"
$outputFile = "C:\temp\Teams_P2P_Call_Report.csv"
$startDate = (Get-Date).AddDays(-10).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
================================
AUTHENTICATION
================================
$body = @{
client_id = $clientId
scope = "https://graph.microsoft.com/.default"
client_secret = $clientSecret
grant_type = "client_credentials"
}
$tokenResponse = Invoke-RestMethod -Method Post
-Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"-Body $body
$headers = @{
Authorization = "Bearer $($tokenResponse.access_token)"
}
Write-Host "Authentication successful." -ForegroundColor Green
================================
INITIAL QUERY
================================
$uri = "https://graph.microsoft.com/beta/communications/callRecords?`$filter=startDateTime ge $startDate"
$results = @()
================================
LOOP THROUGH CALL RECORDS
================================
do {
Write-Host "Querying call records..." -ForegroundColor Yellow
$response = Invoke-RestMethod -Headers $headers -Uri $uri -Method GET
} while ($uri)
================================
EXPORT RESULTS
================================
$results | Export-Csv -Path $outputFile -NoTypeInformation -Encoding UTF8
Write-Host "Report exported to $outputFile" -ForegroundColor Green
SDK Version
2.36.1
Latest version known to work for scenario above?
No response
Known Workarounds
none
Debug output
VERBOSE: GET https://graph.microsoft.com/beta/communications/callRecords/cfd81849-a74d-4d76-8391-bbc7b4cb351c/sessions with
0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Comp
atible=false;charset=utf-8
VERBOSE: GET https://graph.microsoft.com/beta/communications/callRecords/d3ee3eac-1e09-44fa-aec6-0230b4e5e6a0/sessions with
0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Comp
atible=false;charset=utf-8
VERBOSE: GET https://graph.microsoft.com/beta/communications/callRecords/d69f985a-ee03-4074-a658-8a31d820a4f7/sessions with
0-byte payload
VERBOSE: received -1-byte response of content type application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Comp
atible=false;charset=utf-8
Configuration
Name Value
PSVersion 5.1.17763.8276
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.8276
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Other information
I do not know why the data is not returned.