-
|
Thank you for writing this library that makes it easier to manage server-to-server OAuth with Zoom Apps. I'm a Perl script monkey learning to consume APIs with C#. Can you assist with paginating through the response from zoomClient.PastWebinars.GetParticipantsAsync(webinarId)? Visual Studio says the code below cannot convert I've read the README, gone through the project code and looked through the Object/Assembly browser at the definition of PaginatedResponseWithToken. Still confused on what class to define the response as and how to keep returning the token to read the next page of responses. I'm happy to be pointed at a relevant tutorial or existing example. I've looked at a few tutorials, these seem to be on how to create an new API service instead of consuming an existing API. I would appreciate guidance on picking a tutorial on consuming paginated responses compatible with ZoomNet's way of doing things. Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
The Target Framework for this project is .net 7.0 as it is new and shiny. No real dependencies, Target Framework can be changed |
Beta Was this translation helpful? Give feedback.
-
|
The first thing that jumps at me when I look at the code you posted is that you invoke an asynchronous method ( Furthermore, when you await an async method, it's considered best practice to configure the synchronization context by invoking The next thing that is important to understand is that most methods in the ZoomNet library that retrieve a "page" of data, such as GetParticipantsAsync for example, return an object of type
Something else I noticed is that you are attempting to print the name of each participant to the console but the Putting all this together, here's how you can improve the code you posted: // Configure the number of records you want to retrieve at a time
var recordsPerPage = 50;
// Asynchronously retrieve the first "page" of participants
var getParticipantsResult = await zoomClient.PastWebinars.GetParticipantsAsync(webinarId, recordsPerPage).ConfigureAwait(false);
// Loop through the records
foreach (var participant in getParticipantsResult.Records)
{
Console.WriteLine($"- {participant.DisplayName}, {participant.Email}");
}
// Check if there are more records to be retrieved
if (getParticipantsResult.MoreRecordsAvailable)
{
// Retrieve the second "page" of participants
var paginationToken = getParticipantsResult.NextPageToken;
getParticipantsResult = await client.PastWebinars.GetParticipantsAsync(scheduledWebinar.Id, recordsPerPage, paginationToken).ConfigureAwait(false);
foreach (var participant in getParticipantsResult.Records)
{
Console.WriteLine($"- {participant.DisplayName}, {participant.Email}");
}
}Let me know if this helps. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the detailed response, your code is very detailed & looks to be very helpful. You went far and above with your response to my question!
I have not gotten back to my side of this project yet.
|
Beta Was this translation helpful? Give feedback.
-
|
The supplied code works perfectly! Thank you very much! |
Beta Was this translation helpful? Give feedback.
The first thing that jumps at me when I look at the code you posted is that you invoke an asynchronous method (
GetParticipantsAsyncin this case) but you do not await the result. The consequence of this is that yourparticipantsvariable contains a non-completed taskrather than the data you expect and therefore it explains why you are getting an exception about converting a Threading.Task to another data type.
Furthermore, when you await an async method, it's considered best practice to configure the synchronization context by invoking
.ConfigureAwait(false)which is missing from your code sample. Please note that this is not mandatory, but highly encouraged.The next thing that is impor…