DavKa
DavKa

Reputation: 326

AWS Boto SNS invalid parameter topic name

I am trying to send out push messages to iphones using SNS and Boto (python).

The code works fine when I set a normal SNS topic to publish to (replacing the device='xxx' below) but when I replace the arn with that of an application or device registered in that application it complains with the following:

boto.exception.BotoServerError: BotoServerError: 400 Bad Request
{"Error":{"Code":"InvalidParameter","Message":"Invalid parameter: Topic Name","Type":"Sender"},"RequestId":"ee1fa01c-3b01-52be-9ca2-ed42c6748e40"}

The problem is that I dont even have a parameter that is called Topic Name. The boto documentation at http://boto.readthedocs.org/en/latest/ref/sns.html the section about publish is one of the worst documentations I have ever seen. Have anyone read it at all?

The code looks like this:

from boto.sns import connect_to_region

AWS_KEY = '--REMOVED--'
AWS_SECRET = '--REMOVED--'

def push(subject, message, device = u'arn:aws:sns:eu-west-1:606448161548:app/APNS_SANDBOX/SkygdIphone'):
    c = connect_to_region('eu-west-1', aws_access_key_id = AWS_KEY, aws_secret_access_key = AWS_SECRET)

    c.publish(
        device,
        message,
        subject)

push('subject', 'message')

Any suggestions, I am banging my head against this one now for some time.

Upvotes: 2

Views: 4551

Answers (1)

garnaat
garnaat

Reputation: 45856

I think the problem is that you are relying on the order of parameters to the publish method and they are not what you are expecting.

Instead, try this:

c.publish(message=message, subject=subject, target_arn=device)

and see if you get better results.

Upvotes: 3

Related Questions