NotificationMessagesClient.Send 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
Send(NotificationContent, CancellationToken) |
Sends a notification message from Business to User. |
Send(RequestContent, RequestContext) |
[Protocol Method] Sends a notification message from Business to User.
|
Send(NotificationContent, CancellationToken)
Sends a notification message from Business to User.
public virtual Azure.Response<Azure.Communication.Messages.SendMessageResult> Send (Azure.Communication.Messages.NotificationContent notificationContent, System.Threading.CancellationToken cancellationToken = default);
abstract member Send : Azure.Communication.Messages.NotificationContent * System.Threading.CancellationToken -> Azure.Response<Azure.Communication.Messages.SendMessageResult>
override this.Send : Azure.Communication.Messages.NotificationContent * System.Threading.CancellationToken -> Azure.Response<Azure.Communication.Messages.SendMessageResult>
Public Overridable Function Send (notificationContent As NotificationContent, Optional cancellationToken As CancellationToken = Nothing) As Response(Of SendMessageResult)
Parameters
- notificationContent
- NotificationContent
Details of the message to send.
- cancellationToken
- CancellationToken
The cancellation token to use.
Returns
Exceptions
notificationContent
is null.
Examples
This sample shows how to call Send.
NotificationMessagesClient client = new NotificationMessagesClient(null);
NotificationContent notificationContent = new TextNotificationContent(Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"), new string[] { "<to>" }, "<content>");
Response<SendMessageResult> response = client.Send(notificationContent);
This sample shows how to call Send with all parameters.
NotificationMessagesClient client = new NotificationMessagesClient(null);
NotificationContent notificationContent = new TextNotificationContent(Guid.Parse("73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a"), new string[] { "<to>" }, "<content>");
Response<SendMessageResult> response = client.Send(notificationContent);
Applies to
Send(RequestContent, RequestContext)
[Protocol Method] Sends a notification message from Business to User.
- This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
- Please try the simpler Send(NotificationContent, CancellationToken) convenience overload with strongly typed models first.
public virtual Azure.Response Send (Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member Send : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.Send : Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function Send (content As RequestContent, Optional context As RequestContext = Nothing) As Response
Parameters
- 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
content
is null.
Service returned a non-success status code.
Examples
This sample shows how to call Send and parse the result.
NotificationMessagesClient client = new NotificationMessagesClient(null);
using RequestContent content = RequestContent.Create(new
{
kind = "text",
content = "<content>",
channelRegistrationId = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
to = new object[]
{
"<to>"
},
});
Response response = client.Send(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("receipts")[0].GetProperty("messageId").ToString());
Console.WriteLine(result.GetProperty("receipts")[0].GetProperty("to").ToString());
This sample shows how to call Send with all request content and parse the result.
NotificationMessagesClient client = new NotificationMessagesClient(null);
using RequestContent content = RequestContent.Create(new
{
kind = "text",
content = "<content>",
channelRegistrationId = "73f411fe-4f43-4b4b-9cbd-6828d8f4cf9a",
to = new object[]
{
"<to>"
},
});
Response response = client.Send(content);
JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("receipts")[0].GetProperty("messageId").ToString());
Console.WriteLine(result.GetProperty("receipts")[0].GetProperty("to").ToString());