Python-slack-sdk: Unexpected keyword argument 'channel'

Created on 17 Jul 2020  路  2Comments  路  Source: slackapi/python-slack-sdk

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [ ] enhancement (feature request)
  • [x] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [X] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

slackclient version: 2.7.2

python version: 3.7

OS version(s): MacOS 10.15

Steps to reproduce:

1.
2.
3.

Expected result:

What you expected to happen: Post a message to the specified slack channel

Actual result: Error

What actually happened: Error

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

self.slack_client.api_call( "chat.postMessage", channel=ChannelName Or Channel Id, #Using the right channel name/id here text=SomeMessage #Using a random string

I am expecting this method to post a message. But this code errors out with api_call() got an unexpected keyword argument 'channel'. Am I missing some parameter or am I calling the method wrong? Not sure as to why it errors out. The method slack_client.chat_postMessage works fine, but not slack_client.api_call

2x question web-client

Most helpful comment

馃憢 Thanks for asking!

For the general api_call method you should pass a dictionary of the API arguments to the json parameter in this case. In fact, it looks like this example in the docs is exactly like your own example.

client.api_call(
  api_method='chat.postMessage',
  json={'channel': '#random', 'text': 'Hello world!'}
)

All 2 comments

馃憢 Thanks for asking!

For the general api_call method you should pass a dictionary of the API arguments to the json parameter in this case. In fact, it looks like this example in the docs is exactly like your own example.

client.api_call(
  api_method='chat.postMessage',
  json={'channel': '#random', 'text': 'Hello world!'}
)

This be beautiful. This worked. Thank You!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tinoargentino picture tinoargentino  路  3Comments

ErikKalkoken picture ErikKalkoken  路  3Comments

marshallino16 picture marshallino16  路  3Comments

schlegelp picture schlegelp  路  3Comments

Terrance picture Terrance  路  3Comments