PRAW raising RequestException when I try to run simple bot

816 views Asked by At

I'm trying to write a redditbot; I decided to start with a simple one, to make sure I was doing things properly, and I got a RequestException.

my code (bot.py):

import praw

for s in praw.Reddit('bot1').subreddit("learnpython").hot(limit=5):
    print s.title

my praw.ini file:

# The URL prefix for OAuth-related requests.
oauth_url=https://oauth.reddit.com

# The URL prefix for regular requests.
reddit_url=https://www.reddit.com

# The URL prefix for short URLs.
short_url=https://redd.it

[bot1]
client_id=HIDDEN
client_secret=HIDDEN
password=HIDDEN
username=HIDDEN
user_agent=ILovePythonBot0.1

(where HIDDEN replaces the actual id, secret, password and username.)

my Traceback:

Traceback (most recent call last):
  File "bot.py", line 3, in <module>
    for s in praw.Reddit('bot1').subreddit("learnpython").hot(limit=5):
  File "/usr/local/lib/python2.7/dist-packages/praw/models/listing/generator.py", line 79, in next
    return self.__next__()
  File "/usr/local/lib/python2.7/dist-packages/praw/models/listing/generator.py", line 52, in __next__
    self._next_batch()
  File "/usr/local/lib/python2.7/dist-packages/praw/models/listing/generator.py", line 62, in _next_batch
    self._listing = self._reddit.get(self.url, params=self.params)
  File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 322, in get
    data = self.request('GET', path, params=params)
  File "/usr/local/lib/python2.7/dist-packages/praw/reddit.py", line 406, in request
    params=params)
  File "/usr/local/lib/python2.7/dist-packages/prawcore/sessions.py", line 131, in request
    params=params,  url=url)
  File "/usr/local/lib/python2.7/dist-packages/prawcore/sessions.py", line 70, in _request_with_retries
    params=params)
  File "/usr/local/lib/python2.7/dist-packages/prawcore/rate_limit.py", line 28, in call
    response = request_function(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/prawcore/requestor.py", line 48, in request
    raise RequestException(exc, args, kwargs)
prawcore.exceptions.RequestException: error with request request() got an unexpected keyword argument 'json'

Any help would be appreciated. PS, I am using Python 2.7., on Ubuntu 14.04. Please ask me for any other information you may need.

1

There are 1 answers

6
Bantu On

The way i see it, it seems you have a problem with your request to Reddit API. Maybe try changing the user-agent in your in-file configuration. According to PRAW basic configuration Options the user-agent should follow a format <platform>:<app ID>:<version string> (by /u/<reddit username>) . Try that see what happens.