Skip to content

Site.users_by_name is defunct #74

Description

@f4lco

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions