bolt-python: Error in chat_postMessage method

I tried the following code:

block = [{"type": "section","text": {"type": "mrkdwn","text": "Erro na consulta " + str(datetime.now())}}]
client_bot.chat_postMessage(channel=channel_id, blocks = block)

And i got the answer:

Failed to run listener function (error: The request to the Slack API failed. (url: https://www.slack.com/api/chat.postMessage)
The server responded with: {'ok': False, 'error': 'invalid_blocks', 'errors': ['invalid_url [json-pointer:/blocks/0/slack_file.url]'], 'response_metadata': {'messages': ['[ERROR] invalid_url [json-pointer:/blocks/0/slack_file.url]']}})

This same code ran successfully about four hours earlier, but now it has this error.

Can anyone help me?

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 21 (11 by maintainers)

Most upvoted comments

Glad you got it fixed!

FYI, we actually will be rolling back the new slack_file property / feature of image blocks today due to various issues it caused for customers (including the problem you experienced earlier). So please continue using the image_url property as I see you are doing in your last screenshot for the time being.

I will close this issue now but if you have further issues here, feel free to re-open or file a new issue.

@filmaj i solved!! 😃

I just use the same token at the following parts:

Starting bot at the beggining of code: image

Upload file (image) in slack cloud. image

And for send file, i used the method below:

image

Sure! I appreciate contribute into this task!

But i dont fix error yet. Now, i tried like this:

client = WebClient(token=SLACK_USER_OAUTH_TOKEN)

result = client.files_upload(channel=channel_id,file=path, initial_comment = 'Rentabilidades')
result_url = client.files_sharedPublicURL(file = result['file']['id'])

website = result_url['file']['permalink']
print(website)

And the block used was:


say(

            blocks = [
                
                {
                    "type": "section",
                    "text": {
                        "type": "plain_text",
                        "text": 'Última atualização: '+str(infos[1])+' '+str(infos[2]) + ' | ITD do IPCA é o mesmo do FOCUS FIC FIA (2020-12-28)\n'
                    },
                    "accessory": {
                        "type": "image",
                        "slack_file": {
                            "url": infos[0]
                        },
                        "alt_text": "Rentabilidades"
                    }
                }

                
            ]
        )

I got the same error:

image

Note that infos[0] = “https://indiecapitalworkspace.slack.com/files/U01HSA5NLH4/F06F1SJ08SC/rentabilidades.png

Sure!

The block is below:


say(

            blocks = [
                
                {
                    "type": "section",
                    "text": {
                        "type": "plain_text",
                        "text": 'Última atualização: '+str(infos[1])+' '+str(infos[2]) + ' | ITD do IPCA é o mesmo do FOCUS FIC FIA (2020-12-28)'
                    },
                    "accessory": {
                        "type": "image",
                        "slack_file": {
                            "url": infos[0]
                        },
                        "alt_text": "Rentabilidades"
                    }
                }
            ]
        )

Where:

infos[0] = "https://files.slack.com/files-pri/T01J6BY2VEU-F06ERESRXUZ/rentabilidades.png?pub_secret=aa3396340f"