0

I am using flask oauthlib library . I am successfully getting get request however when I am trying update using post , I am getting back 404 not found error I am following the standard example they gave on the git page https://github.com/lepture/flask-oauthlib/blob/master/example/reddit.py

I am making post request by (continuing the example of the git page)

body = {
    'kind' :  'self', 
    'sr'    : 'dev_playspace', 
    'title' :  "test playspace", 
    'text' : 'test text'
}
response = reddit.post('submit' , data=body); 

return jsonify({'response' :  response.data})

I have logged what library is actually sending. url : https://oauth.reddit.com/api/v1/submit

header : {'Content-Type': 'application/x-www-form-urlencoded', u'Authorization': u'Bearer Q7opsQbQ2ZJBruwC1zZATlLi-Fc'}

body looks like
sr=dev_playspace&kind=self&text=test+text&title=test+playspace

method : POST

Reddit api is responding with

{ "error": 404, "message": "Not Found" }

this is pretty confusing message. the subreddit is there (test subreddit /r/dev_playspace ) , and it seems like I am sending correct payload and url

Mr. Snuffles
  • 33
  • 2
  • 6
  • So what are you trying to do? Hard to tell what your issue is. – Mike Tung Jan 15 '18 at 01:09
  • ok I am adding more details basically reddit api is responding with {error : 404 , message: "not found"} – Mr. Snuffles Jan 15 '18 at 01:15
  • Are you sure the url is right? and are you encoding `data=body` as proper json? – Mike Tung Jan 15 '18 at 01:21
  • I followed reddit's documentation. I have also implemented this request in javascript(react native) . However I am keep getting stuck in python . https://www.reddit.com/dev/api/#POST_api_submit – Mr. Snuffles Jan 15 '18 at 01:35
  • can you try before `response` add `body = json.dumps(body)`? I wonder if it's how you are sending it. The headers don't seem right to me. – Mike Tung Jan 15 '18 at 01:37

1 Answers1

0

I'm the author of Flask-OAuthlib. It is suggested that you use Authlib instead. There is a loginpass library which contains the implementation of reddit.

lepture
  • 2,307
  • 16
  • 18