I'm trying to get some JSON data from a subreddit with Ruby; but it fails, returning a 429 error.
begin
request = URI.open(
'https://www.reddit.com/r/vintageobscura.json',
{
"User-Agent"=>"web:myapp:v1.0.0 (by /u/myusername)"
}
);
rescue OpenURI::HTTPError => error
response = error.io
raise StandardError.new sprintf('Error while opening document: %s',response.status)
#puts response.string
end
end
It works when I load the URL in my browser; and as you see, I have a user-agent defined as per their API rules.
Any idea of why it fails ?
Thanks a lot !