Skip to content Skip to sidebar Skip to footer

Error Sending A Sms With Amazon Sns And Python And Boto3

The documentation suggests to use the script below but I can't seem to figure out why im getting an error message. This what im using so far: sns = boto3.client('sns', region_name=

Solution 1:

I was able to get it working with the following code:

importboto3sns= boto3.client('sns')
smsattrs = {
    'AWS.SNS.SMS.SenderID': { 'DataType': 'String', 'StringValue': 'TestSender' },
    'AWS.SNS.SMS.SMSType': { 'DataType': 'String', 'StringValue': 'Transactional'}
}
sns.publish(
    PhoneNumber = '+35840xxxxxxx',
    Message = 'Hello world!',
    MessageAttributes = smsattrs
)

The biggest difference I see is that you have not set AWS.SNS.SMS.SMSType.

Solution 2:

Documentation says that PhoneNumber is supported. http://boto3.readthedocs.io/en/latest/reference/services/sns.html

Sadly, that's just copy-paste from official AWS documentation.

If you look at source code, you'll see that Boto3 expects either TargetArn or TopicArn: https://github.com/boto/boto3/blob/master/boto3/data/sns/2010-03-31/resources-1.json

"Publish":{"request":{"operation":"Publish","params":[{"target":"TopicArn","source":"identifier","name":"Arn"}]}},

...

"Publish":{"request":{"operation":"Publish","params":[{"target":"TargetArn","source":"identifier","name":"Arn"}]}},

So I guess you have to patch Boto3 yourself or file an issue on GitHub.

Post a Comment for "Error Sending A Sms With Amazon Sns And Python And Boto3"