3

I'm working on a code that sends text messages from an ATM when they go over £200, however, when i run the code i get the error

botocore.exceptions.ParamValidationError: Parameter validation failed: Unknown parameter in input: "PhoneNumber", must be one of: TopicArn, TargetArn, Message, Subject, MessageStructure, MessageAttributes

my code is:

import boto3
client = boto3.client('sns','eu-west-1')
client.publish(PhoneNumber='+44XXXXXXXXXX', Message= 'Hello')

Where the X's reference a phone number

2 Answers 2

3

I have examined your Python code snippet and I can confirm to the best of my ability there's nothing wrong with your code nor your code structure.

From the error, the issue is more related to the boto3 version i.e you are most likely using an older version of boto3 hence the old version is not able to pick-up the required parameter "PhoneNumber"

Resolution Steps:

1. Check the current version of boto3 :

pip show boto3

or

>>> import boto3
>>> boto3.__version__

If the output is anything less than the current version (1.11.9) then proceed to upgrade your boto3 version as shown below.

2. Upgrade your boto3:

pip install botocore --upgrade
pip install boto3 --upgrade

Note: You'll need to log out for the changes to take effect

Hope this helps!

Sign up to request clarification or add additional context in comments.

1 Comment

Glad to hear it's working. Would you kindly accept my answer to assist other users
0

Running this locally with my credentials and phone number, a message sends with no issues -

import boto3

sns = boto3.client('sns', region_name='eu-west-1',
                   aws_access_key_id='xxxx',
                   aws_secret_access_key='xxxxx',
                   aws_session_token='xxxxx')
sns.publish(PhoneNumber='+44xxxxxxxxxx', Message= 'Hello')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.