Python-slack-sdk: Can't call exclude_archived

Created on 21 Jan 2021  路  2Comments  路  Source: slackapi/python-slack-sdk

Can't call api_call('conversations.list', exclude_archived=1)

Reproducible in:

The Slack SDK version

slackclient==2.9.3

Python runtime version

Python 3.7.9

OS info

FreeBSD 12.2-RELEASE-p2 amd64

Steps to reproduce:

def get_bot_channels(self):
        channels = self.sc.api_call('conversations.list', exclude_archived=1)
        channels_list = channels['channels']

        memberships = []

        for channel in channels_list:
            if self.SLACK_BOT_ID in channel['members']:
                memberships.append(channel['id'])

        return memberships

Expected result:

Exclude archived conversations.

Actual result:

TypeError: api_call() got an unexpected keyword argument 'exclude_archived'

question

Most helpful comment

That worked perfectly. Thank you.

All 2 comments

Hi @alvawa27 馃憢馃徎 thanks for providing the details and code sample (it always helps out a lot)!

When using the api_call method, you can pass the extra params with the json key:

response = client.api_call(
    api_method='conversations.list',
    json={ 'exclude_archived': 1 }
)

Here are more detailed docs:

Would you mind giving that suggestion a try and letting me know how it goes? Thanks!

That worked perfectly. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kompotkot picture kompotkot  路  4Comments

Terrance picture Terrance  路  3Comments

sushiparlour picture sushiparlour  路  5Comments

schlegelp picture schlegelp  路  3Comments

charlesreid1 picture charlesreid1  路  3Comments