ConversationThreadClient.GetMessages Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
GetMessages(String, Nullable<Int32>, String, RequestContext) |
[Protocol Method] Retrieves list of conversation messages.
|
GetMessages(String, Nullable<Int32>, String, CancellationToken) |
Retrieves list of conversation messages. |
GetMessages(String, Nullable<Int32>, String, RequestContext)
- Source:
- ConversationThreadClient.cs
[Protocol Method] Retrieves list of conversation messages.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler GetMessages(String, Nullable<Int32>, String, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Pageable<BinaryData> GetMessages(string conversationId, int? maxPageSize, string participantId, Azure.RequestContext context);
abstract member GetMessages : string * Nullable<int> * string * Azure.RequestContext -> Azure.Pageable<BinaryData>
override this.GetMessages : string * Nullable<int> * string * Azure.RequestContext -> Azure.Pageable<BinaryData>
Public Overridable Function GetMessages (conversationId As String, maxPageSize As Nullable(Of Integer), participantId As String, context As RequestContext) As Pageable(Of BinaryData)
Parameters
- conversationId
- String
The conversation ID.
- participantId
- String
The participant user ID.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The Pageable<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
conversationId
is null.
conversationId
is an empty string, and was expected to be non-empty.
Service returned a non-success status code.
Examples
This sample shows how to call GetMessages and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
foreach (BinaryData item in client.GetMessages("<conversationId>", null, null, null))
{
JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("message").GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("senderCommunicationIdentifier").ToString());
Console.WriteLine(result.GetProperty("createdOn").ToString());
}
This sample shows how to call GetMessages with all parameters and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
foreach (BinaryData item in client.GetMessages("<conversationId>", 1234, "<participantId>", null))
{
JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("sequenceId").ToString());
Console.WriteLine(result.GetProperty("message").GetProperty("kind").ToString());
Console.WriteLine(result.GetProperty("senderDisplayName").ToString());
Console.WriteLine(result.GetProperty("senderCommunicationIdentifier").ToString());
Console.WriteLine(result.GetProperty("createdOn").ToString());
}
Applies to
GetMessages(String, Nullable<Int32>, String, CancellationToken)
- Source:
- ConversationThreadClient.cs
Retrieves list of conversation messages.
public virtual Azure.Pageable<Azure.Communication.Messages.ConversationMessageItem> GetMessages(string conversationId, int? maxPageSize = default, string participantId = default, System.Threading.CancellationToken cancellationToken = default);
abstract member GetMessages : string * Nullable<int> * string * System.Threading.CancellationToken -> Azure.Pageable<Azure.Communication.Messages.ConversationMessageItem>
override this.GetMessages : string * Nullable<int> * string * System.Threading.CancellationToken -> Azure.Pageable<Azure.Communication.Messages.ConversationMessageItem>
Public Overridable Function GetMessages (conversationId As String, Optional maxPageSize As Nullable(Of Integer) = Nothing, Optional participantId As String = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Pageable(Of ConversationMessageItem)
Parameters
- conversationId
- String
The conversation ID.
- participantId
- String
The participant user ID.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
conversationId
is null.
conversationId
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call GetMessages.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
foreach (ConversationMessageItem item in client.GetMessages("<conversationId>"))
{
}
This sample shows how to call GetMessages with all parameters.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
foreach (ConversationMessageItem item in client.GetMessages("<conversationId>", maxPageSize: 1234, participantId: "<participantId>"))
{
}