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

Site.users_by_name is defunct #74

Open
f4lco opened this issue Nov 12, 2020 · 0 comments
Open

Site.users_by_name is defunct #74

f4lco opened this issue Nov 12, 2020 · 0 comments

Comments

@f4lco
Copy link

f4lco commented Nov 12, 2020

I do appreciate the shorthand users_by_name. However, users_by_name results in a bad request. See below example what does not work, and what my current workaround looks like:

>>> import stackexchange as se
>>> site = se.Site(se.StackOverflow)
>>> site.users_by_name('f4lco')  # This does not work
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/site.py", line 230, in users_by_name
    return self.users(**kw)
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/site.py", line 226, in users
    return self._get(User, ids, 'users', kw)
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/site.py", line 213, in _get
    return self.build(root, typ, coll, kw)
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/site.py", line 190, in build
    json = self._request(url, kw)
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/site.py", line 161, in _request
    json, info = request_mgr.json_request(url, new_params)
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/web.py", line 163, in json_request
    req = self.request(to, params)
  File "/Users/.../py3.9/lib/python3.9/site-packages/stackexchange/web.py", line 150, in request
    raise StackExchangeError(error_ob.get('error_id', StackExchangeError.UNKNOWN), error_ob.get('error_name'), error_ob.get('error_message'))
stackexchange.core.StackExchangeError: 400 [bad_parameter]: Invalid filter specified
>>> site.users(inname='f4lco')  # This does work, but it's not really obvious
(<User 'f4lco' (345057) @ 10e9d9c40>, <User 'wiref4lcon' (13192697) @ 10e9eca90>)

I'm running OS X, Python 3.9, and Py-StackExchange 2.2.7.

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

No branches or pull requests

1 participant