AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Sends a message to an Amazon SNS topic, a text message (SMS message) directly to a phone number, or a message to a mobile platform endpoint (when you specify the TargetArn).

If you send a message to a topic, Amazon SNS delivers the message to each endpoint that is subscribed to the topic. The format of the message depends on the notification protocol for each subscribed endpoint.

When a messageId is returned, the message is saved and Amazon SNS immediately delivers it to subscribers.

To use the Publish action for publishing a message to a mobile endpoint, such as an app on a Kindle device or mobile phone, you must specify the EndpointArn for the TargetArn parameter. The EndpointArn is returned when making a call with the CreatePlatformEndpoint action.

For more information about formatting messages, see Send Custom Platform-Specific Payloads in Messages to Mobile Devices.

You can publish messages only to topics and endpoints in the same Amazon Web Services Region.

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to PublishAsync.

Namespace: Amazon.SimpleNotificationService
Assembly: AWSSDK.SimpleNotificationService.dll
Version: 3.x.y.z

Syntax

C#
public virtual PublishResponse Publish(
         PublishRequest request
)

Parameters

request
Type: Amazon.SimpleNotificationService.Model.PublishRequest

Container for the necessary parameters to execute the Publish service method.

Return Value


The response from the Publish service method, as returned by SimpleNotificationService.

Exceptions

ExceptionCondition
AuthorizationErrorException Indicates that the user has been denied access to the requested resource.
EndpointDisabledException Exception error indicating endpoint disabled.
InternalErrorException Indicates an internal service error.
InvalidParameterException Indicates that a request parameter does not comply with the associated constraints.
InvalidParameterValueException Indicates that a request parameter does not comply with the associated constraints.
InvalidSecurityException The credential signature isn't valid. You must use an HTTPS endpoint and sign your request using Signature Version 4.
KMSAccessDeniedException The ciphertext references a key that doesn't exist or that you don't have access to.
KMSDisabledException The request was rejected because the specified Amazon Web Services KMS key isn't enabled.
KMSInvalidStateException The request was rejected because the state of the specified resource isn't valid for this request. For more information, see Key states of Amazon Web Services KMS keys in the Key Management Service Developer Guide.
KMSNotFoundException The request was rejected because the specified entity or resource can't be found.
KMSOptInRequiredException The Amazon Web Services access key ID needs a subscription for the service.
KMSThrottlingException The request was denied due to request throttling. For more information about throttling, see Limits in the Key Management Service Developer Guide.
NotFoundException Indicates that the requested resource does not exist.
PlatformApplicationDisabledException Exception error indicating platform application disabled.
ValidationException Indicates that a parameter in the request is invalid.

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

See Also