If you’re getting an InvalidParametersException when trying to send media through AWS End User Messaging Social, don’t worry. This error usually happens when the parameters for your media file aren’t set correctly. The most common mistake is specifying both the sourceS3File and sourceS3PresignedUrl at the same time or leaving both out. Make sure you’re only providing one of these options, but since you’re already doing that, here are some other things to check:
First, verify that your phone number is properly linked to a WhatsApp Business Account (WABA). AWS verifies that the originPhoneNumberId has the right permissions to send media files. If the phone number isn’t correctly associated with an active WABA or there’s any issue with the connection, you’ll see this error. Double-check that your phone number’s WABA setup is correct and active.
Next, review your S3 bucket permissions. The service needs access to your media files, so make sure that:
– The bucket policy allows AWS End User Messaging Social to read objects.
– There are no restrictions like required encryption or special access points that could block access.
– The media file itself doesn’t have restrictive permissions that prevent it from being read.
Then, check your media file’s details. Since your PDF is about 4,851 bytes, confirm that:
– The file is a valid, uncorrupted PDF that WhatsApp can accept.
– The Content-Type metadata on the file is set to “application/pdf.”
– The file meets all of WhatsApp’s specific requirements for PDFs, not just size limits.
Lastly, make sure the messaging service is fully working in your region, especially in ap-south-1. Sometimes, regional restrictions or service outages can cause issues with media uploads.
I suggest confirming that your phone number’s WABA status is correct and that the S3 bucket policies give AWS End User Messaging Social the necessary permissions to access your files. These small checks can often solve the problem rather than focusing only on the parameters you’re passing.
For more details, you can visit the official AWS documentation on sending media messages with WhatsApp, managing media files in S3, or troubleshooting media uploads.
