Reputation: 6179
I am using python for amazon SNS for publishing push notifications.
data = { "GCM" : {"data": {"message": "dummy" }}}
jsonData = json.dumps(data)
self.client.publish( TargetArn=targetArn,
Message= jsonData,
MessageStructure='json')
Getting the below error.
Invalid parameter: JSON must contain an entry for 'default' or 'GCM'.
Tried sending it as string and various formats. But this is not working out. What's wrong with the publish?
Upvotes: 1
Views: 2800
Reputation: 6179
The json strucutre needed by publish had to have \
escaped specifically. Below worked for me. It is important to have a default value and the value of GCM
key should again be a json object.
GCM_data = { 'data' : { 'message' : 'dummy'}}
data = { "default" : "test",
"GCM": json.dumps(GCM_data)
}
jsonData = json.dumps(data)
Upvotes: 6