Aws-sdk-ruby: Publishing SNS message to topic not working

Created on 1 Sep 2013  路  7Comments  路  Source: aws/aws-sdk-ruby

Here is the request and response:

[AWS SNS 400 0.799616 0 retries] publish(:message=>"{\"APNS_SANDBOX\":\"{\"aps\":{\"alert\":\"678978698\",\"sound\":\"default\"}}\"}",:message_structure=>"json",:subject=>"789579",:target_arn=>"arn:aws:sns:us-east-1:208143138780:new-workouts-topic")

AWS::SNS::Errors::InvalidParameter Invalid parameter: Message Structure - No default entry in JSON message body

Completed 500 Internal Server Error in 5446ms

AWS::SNS::Errors::InvalidParameter (Invalid parameter: Message Structure - No default entry in JSON message body):

Most helpful comment

I leave the doc info here for future visits:

be a syntactically valid JSON object; and
contain at least a top-level JSON key of "default" with a value that is a string.
You can define other top-level keys that define the message you want to send to a specific transport protocol (e.g., "http").

All 7 comments

You have to pass a "default" key if you use a JSON payload. See the docs and the example I gave you in the last issue you opened.

Ok. That made it not crash but the device doesn't get the message when the target is a topic that it is subscribed to. It does get a message when I send a message directly to the device's end point.

Am I missing something fundamental here? I thought if I send a message a topic all devices (endpoints) subscribed to that topic would receive it.

@goleador are you suggesting that the solution given in #336 is not working for you anymore? You had mentioned in that issue that it was. Is this issue different from the original one?

If you're having issues with Amazon SNS topics not working as expected, I'd recommend you post on the Amazon SNS Discussion Forum or contact AWS Support.

@goleador, I see that you are sending a message to a topic but you are passing it's ARN it to the target_arn: hash key instead of the topic_arn: hash key. Haven't tried it but that my be the reason.

@lsegal That was directly to a specific device not a topic.

@batianusrey That was the issue thank you.

I leave the doc info here for future visits:

be a syntactically valid JSON object; and
contain at least a top-level JSON key of "default" with a value that is a string.
You can define other top-level keys that define the message you want to send to a specific transport protocol (e.g., "http").

Was this page helpful?
0 / 5 - 0 ratings