I'm building a slackbot which takes images from the Amazon S3 bucket and posts it to a slack channel. I made sure that the Amazon S3 bucket is public. Here's my code :
const slackToken = SLACK_TOKEN;
const url = 'https://slack.com/api/chat.postMessage';
const res = await axios.post(url, {
channel: '#general',
blocks: [
{
type: 'image',
image_url: AWS_S3_BUCKET_URL,
alt_text: 'qrcode'
}
],
username: 'SlackBot',
}, { headers: { authorization: `Bearer ${slackToken}` } });
console.log('Done', res.data);
But it gives me this wierd error
ok: false,
error: 'invalid_blocks',
errors: [ 'downloading image failed [json-pointer:/blocks/0/image_url]' ],
response_metadata: {
messages: [
'[ERROR] downloading image failed [json-pointer:/blocks/0/image_url]'
]
}
}
When I replace the AWS_S3BUCKET_URL with any other url like https://mms.businesswire.com/media/20200513005022/en/791013/22/AWS_logo_RGB.jpg
It works fine, But gives error in case of AWS_S3_BUCKET_URL.