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?

asked 7 months ago398 views
2 Answers
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
EXPERT
answered 7 months ago
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
answered 7 months ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions