ConversationThreadClient.AddParticipants 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
AddParticipants(String, AddParticipantsOptions, CancellationToken) |
Adds participants to a specific conversation. |
AddParticipants(String, RequestContent, RequestContext) |
[Protocol Method] Adds participants to a specific conversation.
|
AddParticipants(String, AddParticipantsOptions, CancellationToken)
- Source:
- ConversationThreadClient.cs
Adds participants to a specific conversation.
public virtual Azure.Response<Azure.Communication.Messages.AddParticipantsResult> AddParticipants(string conversationId, Azure.Communication.Messages.AddParticipantsOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member AddParticipants : string * Azure.Communication.Messages.AddParticipantsOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Communication.Messages.AddParticipantsResult>
override this.AddParticipants : string * Azure.Communication.Messages.AddParticipantsOptions * System.Threading.CancellationToken -> Azure.Response<Azure.Communication.Messages.AddParticipantsResult>
Public Overridable Function AddParticipants (conversationId As String, options As AddParticipantsOptions, Optional cancellationToken As CancellationToken = Nothing) As Response(Of AddParticipantsResult)
Parameters
- conversationId
- String
The conversation ID.
- options
- AddParticipantsOptions
Details of the payload for adding participants to 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 AddParticipants.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
AddParticipantsOptions options = new AddParticipantsOptions(new ConversationParticipant[]
{
new InternalConversationParticipant(new CommunicationContact("<id>"))
});
Response<AddParticipantsResult> response = client.AddParticipants("<conversationId>", options);
This sample shows how to call AddParticipants with all parameters.
Uri endpoint = new Uri("<endpoint>");
TokenCredential credential = new DefaultAzureCredential();
ConversationThreadClient client = new ConversationThreadClient(endpoint, credential);
AddParticipantsOptions options = new AddParticipantsOptions(new ConversationParticipant[]
{
new InternalConversationParticipant(new CommunicationContact("<id>"))
{
DisplayName = "<displayName>",
}
});
Response<AddParticipantsResult> response = client.AddParticipants("<conversationId>", options);
Applies to
AddParticipants(String, RequestContent, RequestContext)
- Source:
- ConversationThreadClient.cs
[Protocol Method] Adds participants to a specific conversation.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler AddParticipants(String, AddParticipantsOptions, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Response AddParticipants(string conversationId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member AddParticipants : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.AddParticipants : string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function AddParticipants (conversationId As String, content As RequestContent, Optional context As RequestContext = Nothing) As 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 AddParticipants 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
{
participants = new object[]
{
new
{
kind = "internal",
contact = new
{
kind = "communication",
id = "<id>",
},
}
},
});
Response response = client.AddParticipants("<conversationId>", content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("invalidParticipants")[0].GetProperty("id").ToString());
This sample shows how to call AddParticipants 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
{
participants = new object[]
{
new
{
kind = "internal",
contact = new
{
kind = "communication",
id = "<id>",
},
displayName = "<displayName>",
}
},
});
Response response = client.AddParticipants("<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());