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?

질문됨 7달 전415회 조회
2개 답변
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
전문가
답변함 7달 전
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
답변함 7달 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠