I couldn't get any help on reddit/r/redditdev so I'm hoping you fine folks at stackoverflow can help
I'm trying to call /api/submit.
Now I try to call submit using nodejs' request module like so
var options = {
url: 'https://oauth.reddit.com/api/submit',
method: 'POST',
headers: {
'Authorization': 'bearer '+usertoken
, 'user-agent': 'node.js'
},
json: data
}
request(options, function(error, response, body) ...
A sample of my "data" variable looks like this:
{ api_type: 'json',
kind: 'self',
sr: 'test',
title: 'more test',
text: 'hello world',
iden: 'o6NsDh4IMCDb2To2DeUXJAgEPkB4O7uS',
captcha: 'WZRTBL' }
But I get this back:
{
"jquery":[
[0, 1, "call", ["body"]],
[1, 2, "attr", "find"],
[2, 3, "call", [".status"]],
[3, 4, "attr", "hide"],
[4, 5, "call", []],
[5, 6, "attr", "html"],
[6, 7, "call", [""]],
[7, 8, "attr", "end"],
[8, 9, "call", []],
[1, 10, "attr", "captcha"],
[10, 11, "call", ["1oWOOhcicpcpdwjENw5KrR2xHRl7J0aS"]],
[1, 12, "attr", "find"],
[12, 13, "call", [".error.BAD_CAPTCHA.field-captcha"]],
[13, 14, "attr", "show"],
[14, 15, "call", []],
[15, 16, "attr", "text"],
[16, 17, "call", ["care to try these again?"]],
[17, 18, "attr", "end"],
[18, 19, "call", []]
]
}
Also, I tried running this as a different user, one that has enough karma points and didn't require the captcha.
After I posted, I got this response which seems to indicate success:
{
"jquery":[
[0, 1, "call", ["body"]],
[1, 2, "attr", "find"],
[2, 3, "call", [".status"]],
[3, 4, "attr", "hide"],
[4, 5, "call", []],
[5, 6, "attr", "html"],
[6, 7, "call", [""]],
[7, 8, "attr", "end"],
[8, 9, "call", []]
]
}
But I can't find my posted message in the /r/test subreddit.
I must be doing something wrong entirely...
After going through different documentation related to /api/submit, I have discovered that you have missed the field uh
of your sample of "data". Missing of uh
entails to errors that look like yours (look documentation below)
Here more documentation related what I said:
https://github.com/reddit/reddit/wiki/API:-submit http://www.reddit.com/dev/api
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With