I am trying to call the Microsoft Teams graph call records get Pstn Calls with the following Java (groovy) code:
ClientSecretCredential credential = new ClientSecretCredentialBuilder().clientId(clientId).tenantId(tenantId).clientSecret(clientSecret).build()
final GraphServiceClient graphClient = new GraphServiceClient(credential, scopes)
var GetPstnCallsWithFromDateTimeWithToDateTimeGetResponse result = graphClient
.communications()
.callRecords()
.microsoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTime(fromDate, toDate).get(requestConfiguration -> {
requestConfiguration.queryParameters.top = 10 })
using the com.microsoft.graph : microsoft-graph : 6.46.0 maven dependency
and it works, except it returns all records and will not honor the top 10 configuration limit. I have traced through the Microsoft components, I see the class
MicrosoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTimeRequestBuilder
and the code at the end adding "%24top" to allQueryParams (the %24 is not a typo). The available parameters available are count, filter, search, skip, and top.
I can then trace that up the call stack to the point wher it creates the actual URL to call, which is RequestInformation.getUri()
which returns
The end of the url says %24top=10, and that was put there by setting requestConfiguration.queryParameters.top = 10
in the latest Microsoft graph Java maven dependency. This follows the Microsoft examples of how to get the top 10 records using the Microsoft Graph client.
My question is why can I not get the microsoft graph api to honor the top 10 limit? The result.odataCount
is in the hundreds and the result.odataNextLink
is null
The Graph SDKs quite often expose query parameters even if the endpoint does not support them. This will likely be the case.
According to the doc the endpoint returns by default 1000 records. If there is more than 1000 records then @odata.nextLink
is not null.
You specified $top
(URL encoded as %24top
) and it's ignored, the endpoint probably doesn't support this query parameter.