Share via


ConversationThreadClient.GetConversationsAsync Method

Definition

Overloads

GetConversationsAsync(Nullable<Int32>, String, Nullable<Guid>, CancellationToken)

Retrieves list of conversations.

GetConversationsAsync(Nullable<Int32>, String, Nullable<Guid>, RequestContext)

[Protocol Method] Retrieves list of conversations.

GetConversationsAsync(Nullable<Int32>, String, Nullable<Guid>, CancellationToken)

Source:
ConversationThreadClient.cs

Retrieves list of conversations.

public virtual Azure.AsyncPageable<Azure.Communication.Messages.CommunicationConversation> GetConversationsAsync(int? maxPageSize = default, string participantId = default, Guid? channelId = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetConversationsAsync : Nullable<int> * string * Nullable<Guid> * System.Threading.CancellationToken -> Azure.AsyncPageable<Azure.Communication.Messages.CommunicationConversation>
override this.GetConversationsAsync : Nullable<int> * string * Nullable<Guid> * System.Threading.CancellationToken -> Azure.AsyncPageable<Azure.Communication.Messages.CommunicationConversation>
Public Overridable Function GetConversationsAsync (Optional maxPageSize As Nullable(Of Integer) = Nothing, Optional participantId As String = Nothing, Optional channelId As Nullable(Of Guid) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As AsyncPageable(Of CommunicationConversation)

Parameters

maxPageSize
Nullable<Int32>

Number of objects to return per page.

participantId
String

The participant user ID.

channelId
Nullable<Guid>

The id of channel.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Examples

This sample shows how to call GetConversationsAsync.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);

await foreach (CommunicationConversation item in client.GetConversationsAsync())
{
}

This sample shows how to call GetConversationsAsync with all parameters.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);

await foreach (CommunicationConversation item in client.GetConversationsAsync(maxPageSize: 1234, participantId: "<participantId>", channelId: Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a")))
{
}

Applies to

GetConversationsAsync(Nullable<Int32>, String, Nullable<Guid>, RequestContext)

Source:
ConversationThreadClient.cs

[Protocol Method] Retrieves list of conversations.

public virtual Azure.AsyncPageable<BinaryData> GetConversationsAsync(int? maxPageSize, string participantId, Guid? channelId, Azure.RequestContext context);
abstract member GetConversationsAsync : Nullable<int> * string * Nullable<Guid> * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
override this.GetConversationsAsync : Nullable<int> * string * Nullable<Guid> * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
Public Overridable Function GetConversationsAsync (maxPageSize As Nullable(Of Integer), participantId As String, channelId As Nullable(Of Guid), context As RequestContext) As AsyncPageable(Of BinaryData)

Parameters

maxPageSize
Nullable<Int32>

Number of objects to return per page.

participantId
String

The participant user ID.

channelId
Nullable<Guid>

The id of channel.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The AsyncPageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.

Exceptions

Service returned a non-success status code.

Examples

This sample shows how to call GetConversationsAsync and parse the result.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);

await foreach (BinaryData item in client.GetConversationsAsync(null, null, null, null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("id").ToString());
}

This sample shows how to call GetConversationsAsync with all parameters and parse the result.

Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);

await foreach (BinaryData item in client.GetConversationsAsync(1234, "<participantId>", Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"), null))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("id").ToString());
    Console.WriteLine(result.GetProperty("topic").ToString());
    Console.WriteLine(result.GetProperty("deliveryChannelIds")[0].ToString());
    Console.WriteLine(result.GetProperty("outboundDeliveryStrategy").ToString());
    Console.WriteLine(result.GetProperty("participants")[0].GetProperty("id").ToString());
    Console.WriteLine(result.GetProperty("participants")[0].GetProperty("displayName").ToString());
    Console.WriteLine(result.GetProperty("participants")[0].GetProperty("kind").ToString());
}

Applies to