Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api_call method returning string, not dict #47

Closed
jcshott opened this issue Oct 22, 2015 · 4 comments · Fixed by #74
Closed

api_call method returning string, not dict #47

jcshott opened this issue Oct 22, 2015 · 4 comments · Fixed by #74

Comments

@jcshott
Copy link

jcshott commented Oct 22, 2015

I was testing the api_call method and couldn't parse - when testing response, I was getting a response as a string, not a dictionary, as the documentation notes.

import time, os
from slackclient import SlackClient

token = os.environ.get("SLACK_TOKEN")
sc = SlackClient(token)

print sc.api_call("api.test")
print type(sc.api_call("api.test"))


get_info = sc.api_call("im.history", channel="D076VAAKY")
print type(get_info)

response from running this script:

$ python slack_test.py
{"ok":true,"args":{"token":"xoxp-6950599446-7233369073-12964712006-aa717de21f"}}
<type 'str'>
<type 'str'>
@rawdigits
Copy link
Contributor

Sorry about that! It appears I always return a string, and was incorrect in the docs. I'll update the docs.

@elementc
Copy link
Contributor

I've provided PRs #70 and #71 to fix this issue. #70 fixes the api_call func to do a json.loads() before returning- I prefer this solution to #71's since it's more consistent with rtm_read()'s returning of dicts. #71 only fixes the docs to show api calls being passed through json.loads(). Take your pick which you merge.

@elementc
Copy link
Contributor

#70 was obsoleted by #74 which also fixes #73 in addition to this issue.

@ravenCondol
Copy link

The examples in the docstring for api_call still say that it returns a string rather than a dict. Minor thing, but thought I'd say in case someone else stumbles on this ahaha

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants