Я использую график SDK в C#, чтобы получить список журналов вызовов PSTN. Некоторые из моих диапазонов дат возвращаются более 1000, а результаты находятся на нескольких страницах. Я не уверен в лучшем способе итерации через результаты, чтобы получить все записи. Я установил целое число и по умолчанию на 0. В первый раз, нанесу его, я говорю о том, чтобы пропустить I*1000. < /P>
var response = await graphClient.Communications.CallRecords.MicrosoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTime(DateTimeOffset.Parse("2024-12-18"), DateTimeOffset.Parse("2024-12-28"))
.GetAsGetPstnCallsWithFromDateTimeWithToDateTimeGetResponseAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Skip = i * 1000;
}
);
< /code>
Тогда я делаю цикл в поисках odatanextlink и увеличения i. Вот полный код, который я работаю сейчас, и я бы признателен, если кто -то сможет поделиться тем, как правильно итерация через результаты. < /P>
// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "xxx";
// Value from app registration
var clientId = "xxx";
var dotNetClientSecret = "xxx";
var tokenCredential = new ClientSecretCredential(
tenantId,
clientId,
dotNetClientSecret
);
// NOTE: Authentication requests will not go through the proxy.
// Azure.Identity token credential classes have their own separate method
// for configuring a proxy using TokenCredentialOptions.Transport
var authProvider = new AzureIdentityAuthenticationProvider(tokenCredential, null, null, isCaeEnabled: true);
var graphClient = new GraphServiceClient(authProvider);
List callLogs = new List();
int i = 0;
var response = await graphClient.Communications.CallRecords.MicrosoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTime(DateTimeOffset.Parse("2024-12-18"), DateTimeOffset.Parse("2024-12-28"))
.GetAsGetPstnCallsWithFromDateTimeWithToDateTimeGetResponseAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Skip = i * 1000;
}
);
var pstnCalls = response.Value;
var nextLink = response.OdataNextLink;
while (!string.IsNullOrEmpty(nextLink))
{
i += 1;
response = await graphClient.Communications.CallRecords.MicrosoftGraphCallRecordsGetPstnCallsWithFromDateTimeWithToDateTime(DateTimeOffset.Parse("2024-12-18"), DateTimeOffset.Parse("2024-12-28"))
.GetAsGetPstnCallsWithFromDateTimeWithToDateTimeGetResponseAsync(requestConfiguration =>
{
requestConfiguration.QueryParameters.Skip = i * 1000;
}
);
pstnCalls.AddRange(response.Value);
nextLink = response.OdataNextLink;
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... tanextlink