ConversationThreadClient.RemoveParticipantsAsync 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
RemoveParticipantsAsync(String, RemoveParticipantsOptions, CancellationToken) |
remove a participant from a conversation. |
RemoveParticipantsAsync(String, RequestContent, RequestContext) |
[Protocol Method] remove a participant from a conversation
|
RemoveParticipantsAsync(String, RemoveParticipantsOptions, CancellationToken)
- Source:
- ConversationThreadClient.cs
remove a participant from a conversation.
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Messages.RemoveParticipantsResult>> RemoveParticipantsAsync(string conversationId, Azure.Communication.Messages.RemoveParticipantsOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member RemoveParticipantsAsync : string * Azure.Communication.Messages.RemoveParticipantsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Messages.RemoveParticipantsResult>>
override this.RemoveParticipantsAsync : string * Azure.Communication.Messages.RemoveParticipantsOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Messages.RemoveParticipantsResult>>
Public Overridable Function RemoveParticipantsAsync (conversationId As String, options As RemoveParticipantsOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Response(Of RemoveParticipantsResult))
Parameters
- conversationId
- String
The conversation ID.
- options
- RemoveParticipantsOptions
Details of the request body for removing participants from a conversation.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
conversationId
or options
is null.
conversationId
is an empty string, and was expected to be non-empty.
Examples
This sample shows how to call RemoveParticipantsAsync.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
RemoveParticipantsOptions options = new RemoveParticipantsOptions(new string[] { "<participantIds>" });
Response<RemoveParticipantsResult> response = await client.RemoveParticipantsAsync("<conversationId>", options);
This sample shows how to call RemoveParticipantsAsync with all parameters.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
RemoveParticipantsOptions options = new RemoveParticipantsOptions(new string[] { "<participantIds>" });
Response<RemoveParticipantsResult> response = await client.RemoveParticipantsAsync("<conversationId>", options);
Applies to
RemoveParticipantsAsync(String, RequestContent, RequestContext)
- Source:
- ConversationThreadClient.cs
[Protocol Method] remove a participant from a conversation
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler RemoveParticipantsAsync(String, RemoveParticipantsOptions, CancellationToken) convenience overload with strongly typed models first.
public virtual System.Threading.Tasks.Task<Azure.Response> RemoveParticipantsAsync(string conversationId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member RemoveParticipantsAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.RemoveParticipantsAsync : string * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function RemoveParticipantsAsync (conversationId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Response)
Parameters
- conversationId
- String
The conversation ID.
- content
- RequestContent
The content to send as the body of the request.
- context
- RequestContext
The request context, which can override default behaviors of the client pipeline on a per-call basis.
Returns
The response returned from the service.
Exceptions
conversationId
or content
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 RemoveParticipantsAsync and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
participantIds = new object[]
{
"<participantIds>"
},
});
Response response = await client.RemoveParticipantsAsync("<conversationId>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("id").ToString());
This sample shows how to call RemoveParticipantsAsync with all parameters and request content and parse the result.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
using RequestContent content = RequestContent.Create(new
{
participantIds = new object[]
{
"<participantIds>"
},
});
Response response = await client.RemoveParticipantsAsync("<conversationId>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("error").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("error").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("error").GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());