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

pynder.errors.RequestError: 400 #193

Open
jasonminsookim opened this issue Mar 13, 2018 · 2 comments
Open

pynder.errors.RequestError: 400 #193

jasonminsookim opened this issue Mar 13, 2018 · 2 comments

Comments

@jasonminsookim
Copy link

jasonminsookim commented Mar 13, 2018

Here's the code I used:

`session = pynder.Session(facebook_id=myId, facebook_token=myToken)

list(session.matches())`

Here's the error I got:
Traceback (most recent call last):
File "/Users/jasonkim/PycharmProjects/JynderBot/brainstorming.py", line 8, in
list(session.matches())
File "/Users/jasonkim/PycharmProjects/JynderBot/venv/lib/python3.5/site-packages/pynder/session.py", line 48, in
return (Match(match, self) for match in response if 'person' in match)
File "/Users/jasonkim/PycharmProjects/JynderBot/venv/lib/python3.5/site-packages/pynder/models/user.py", line 135, in init
match['person']['_id'])['results']
File "/Users/jasonkim/PycharmProjects/JynderBot/venv/lib/python3.5/site-packages/pynder/api.py", line 120, in user_info
return self._get("/user/" + user_id)
File "/Users/jasonkim/PycharmProjects/JynderBot/venv/lib/python3.5/site-packages/pynder/api.py", line 52, in _get
return self._request("get", url)
File "/Users/jasonkim/PycharmProjects/JynderBot/venv/lib/python3.5/site-packages/pynder/api.py", line 46, in _request
raise errors.RequestError(result.status_code)
pynder.errors.RequestError: 400

@PaulAhuevo
Copy link

Hi, there are new "users" (advertisement) that cause problems. I put serveral methods into try / except blocks to handle the error.

Change the pynder code in user.py to something like this and it should work:

        if 'person' in match:
            try:
                _id = match['person']['_id']
                user_data = _session._api.user_info(_id)['results']
                user_data['_id'] = _id
                self.user = User(user_data, _session)
                self.messages = [
                    Message(m, user=self.user)
                    for m in match['messages']
                ]
            except Exception as e:
                print("Not normal user: Advertisement / Deleted: " + str(e))

@acerock6
Copy link

The error still persists even after making the code change you suggested.

`RequestError Traceback (most recent call last)
in
2
3 session = pynder.Session(facebook_id, facebook_auth_token)
----> 4 session.profile

//anaconda3/lib/python3.7/site-packages/cached_property.py in get(self, obj, cls)
33 return self._wrap_in_coroutine(obj)
34
---> 35 value = obj.dict[self.func.name] = self.func(obj)
36 return value
37

//anaconda3/lib/python3.7/site-packages/pynder/session.py in profile(self)
20 @cached_property
21 def profile(self):
---> 22 return Profile(self._api.profile(), self._api)
23
24 def nearby_users(self, limit=10):

//anaconda3/lib/python3.7/site-packages/pynder/api.py in profile(self)
66
67 def profile(self):
---> 68 return self._get("/profile")
69
70 def update_profile(self, profile):

//anaconda3/lib/python3.7/site-packages/pynder/api.py in _get(self, url)
45
46 def _get(self, url):
---> 47 return self._request("get", url)
48
49 def _post(self, url, data={}):

//anaconda3/lib/python3.7/site-packages/pynder/api.py in _request(self, method, url, data)
39 url), data=data, proxies=self._proxies)
40 if result.status_code < 200 or result.status_code >= 300:
---> 41 raise errors.RequestError(result.status_code)
42 if result.status_code == 201 or result.status_code == 204:
43 return {}

RequestError: 400`

Pynder version: 0.0.13

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

3 participants