Python-slack-sdk: channels.history v2api not work

Created on 13 May 2019  路  2Comments  路  Source: slackapi/python-slack-sdk

Description

channels.history of v2api not work
I tryed channels.history api as follows

import slack

slack_token = os.environ["SLACK_API_TOKEN"]
sc = SlackClient(slack_token)
res = sc.api_call("channels.history", json={
        "channel": "CEB1BL1MM",
    })

but, I got error like this

slack.errors.SlackApiError: The request to the Slack API failed.
The server responded with: {'ok': False, 'error': 'channel_not_found', 'warning': 'missing_charset', 'response_metadata': {'warnings': ['missing_charset']}}

With the same settings(token, scope...), I got correct result in v1 api client .
So, I think this is a bug of v2 api .

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

  • [x] bug
  • [ ] enhancement (feature request)
  • [ ] 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.

Reproducible in:

slackclient version: more than 2.0.0

python version: 3.6.5

OS version(s): macOS 10.14.4

2x bug

Most helpful comment

I was working on this and there are two things that I noted in my testing. 1) the "channel:history" permission needs to be granted in the slack API web interface. This is not a programmatic thing, this is an app configuration thing; 2) The "Bot" token cannot be granted permission to this scope, and therefore the regular non-bot token should be used in your code.

So grant permission and swap to the other token - That might fix it.

All 2 comments

Hi @GentaObata, Thanks for trying v2. To run this same code utilizing our new client I'd structure it like so:

from slack import WebClient

slack_token = os.environ["SLACK_API_TOKEN"]
sc = WebClient(slack_token)
res = sc.channels_history(channel="CEB1BL1MM")

Can you try this and let me know if you receive the same error message?

I was working on this and there are two things that I noted in my testing. 1) the "channel:history" permission needs to be granted in the slack API web interface. This is not a programmatic thing, this is an app configuration thing; 2) The "Bot" token cannot be granted permission to this scope, and therefore the regular non-bot token should be used in your code.

So grant permission and swap to the other token - That might fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ErikKalkoken picture ErikKalkoken  路  3Comments

sushiparlour picture sushiparlour  路  5Comments

seratch picture seratch  路  3Comments

vv-grinko picture vv-grinko  路  3Comments

marshallino16 picture marshallino16  路  3Comments