Aws-sdk-js: Can not send sms via SNS

Created on 10 Nov 2016  路  5Comments  路  Source: aws/aws-sdk-js

Hi!
I'm trying send sms via SNS, but getting error

InvalidParameter: Invalid parameter: PhoneNumber Reason: +66XX0122520 is not valid to publish to

Example:

...
const sns = new AWS.SNS();
sns.setSMSAttributes({
    attributes: {
        DefaultSenderID: 'test',
        DefaultSMSType: 'Transactional'
    }
});
sns.publish({
    Message: 'Hello World',
    PhoneNumber: '66XX0122520'
}, function(err, data) {
    if (err) {
        console.log(err.stack);
        return;
    }

    console.log('push sent');
    console.log(data);
});

What i do wrong? The phone number has standard E.164.

service-api

Most helpful comment

Just in case anyone ever runs into this, it may be caused by an incorrect region. For me I chose us-west-1 which is not a supported SMS region. List of supported regions here: http://docs.aws.amazon.com/sns/latest/dg/sms_supported-countries.html

All 5 comments

Instead of PhoneNumber try TopicArn: SNSTopicArn that did the trick for Android.
You need to choose either PhoneNumber or TopicArn, can't have both

Also, You are missing + in "PhoneNumber: '66XX0122520'"

Hope that helps.

@evseevnn
If @fshirzadi's suggestion didn't fix your issue, please feel free to make a post on the AWS SNS forums. The service team will be better equipped to answer questions related to how their API works.

Just in case anyone ever runs into this, it may be caused by an incorrect region. For me I chose us-west-1 which is not a supported SMS region. List of supported regions here: http://docs.aws.amazon.com/sns/latest/dg/sms_supported-countries.html

And make sure your actual DefaultSenderID is valid: No spaces, Max 11 alphanumerical chars.
I had something like 'Test App' and it would complain about InvalidParameter

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings