invalid `trigger_id` modal.push
See original GitHub issueI found a bug in Shortcut Modal Push (https://api.slack.com/surfaces/modals/using#pushing_api).
I created a modal by this guide (https://github.com/slackapi/python-slackclient/blob/a86536766274b02f8e6a7532f9b5494f1a8ae354/docs-src/basic_usage.rst#opening-a-modal) and filled it with proper elements (input, submit and etc.) and everything works fine in slack. But when I send client.views_push()
I get an error from slack’s server invalid 'trigger_id'
Also I tried to reproduce this issue without python-slackclient
using requests
library and got same result. According to logs I respond to server less then 3 second.
Reproducible in:
client = WebClient(token=slack_token)
view = {
"type": "modal",
"title": {"type": "plain_text", "text": "Show me result"},
"blocks": []
}
try:
api_response = client.views_push(
trigger_id=payload["trigger_id"],
view=view,
)
logger.info(api_response)
except Exception as e:
logger.error(repr(e))
raise
The Slack SDK version
slackclient==2.8.2
Python runtime version
Python 3.8.2
OS info
Linux semu 5.4.0-47-generic #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Steps to reproduce:
- if payload[“type”] == “shortcut”: api_response = client.views_open()
- elif payload[“type”] == “view_submission”: api_response = client.views_push()
Expected result:
Expected result [‘ok’] == True and slack API except trigger_id.
Actual result:
slack.errors.SlackApiError: The request to the Slack API failed. The server responded with: {'ok': False, 'error': 'invalid_arguments', 'response_metadata': {'messages': ['[ERROR] invalid 'trigger_id' [json-pointer:/trigger_id]']}}
Requirements
For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇
Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Hi @kompotkot thanks for writing in!
In response to a
view_submission
type request, please useresponse_action: push
in its HTTP response instead of callingviews.push
API methods. Refer to this document for details: https://api.slack.com/surfaces/modals/using#pushing_viewsIf you’re using Flask as with the doc you mentioned, constructing a JSON response body containing
response_action: push
andview
, plus building an HTTP response using Flask’smake_response
utility method should work for you.As I’ve already answered the question here, let me close this issue now. Thanks for asking the question!