Amazon SNS message saying error "Message body is invalid"

0

I am using Amazon SNS service for sending transactional message in India with proper Entity id and template id (approved) but when I am watching SNS log.. I noticed 1 message is being delived out of 10 and giving "Message body is invalid" for remaining 9.

Can anybody me provide the solution how it can be resolved?

gefragt vor 7 Monaten415 Aufrufe
2 Antworten
1

Hi,

Please, have a look at this post for potential causes of such error when sending SMS: https://repost.aws/knowledge-center/sns-unknown-error-phone-sms

Best,

Didier

profile pictureAWS
EXPERTE
beantwortet vor 7 Monaten
0

Do you use JSON format message? In this case, the message body should be a well-formatted JSON, otherwise the message body will be invalid.

profile picture
HS
beantwortet vor 7 Monaten
  • Yes. It is using Amazon SDK API to send message. As I said, some messgaes are being delived and many messages are giving this error. If message body will be improper than it might happen for all the messages.

  • Have you logged the message body for each message before you sent? e.g.,

    const messageBody = readFromTemplate(entityId, templateId);
    console.log(messageBody); // logging for debug
    
    // Send message
    const publishCommand = new PublishCommand({
      Message: messageBody,
      // ... rest of args
    });
    await snsClient.send(publishCommand);

    You might notice incorrect message body for some of the message.

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen