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 .
x in one of the [ ])x in each of the [ ])slackclient version: more than 2.0.0
python version: 3.6.5
OS version(s): macOS 10.14.4
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.
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.