I keep getting this error when trying to use the imgur search api in nodejs:
{"data":{"error":"Imgur is temporarily over capacity. Please try again later."},"success":false,"status":500}
I dont get this error when accessing the api through a REST client which makes me think I'm doing something wrong. When I use the REST client I get the results I expect. This is how I'm accessing the api in node.
var https = require("https");
var options = {
protocol:"https:",
host:"api.imgur.com",
path:"3/gallery/search/top/all/0?q=cats",
headers:{"Authorization" : "Client-ID ***********"}
}
var req = https.request(options, function(response) {
var str = '';
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
console.log(str);
});
});
req.end();
Your path
in the request options
is incorrect. Prepend /
and voila!
Simply change:
path:"3/gallery/search/top/all/0?q=cats",
to
path:"/3/gallery/search/top/all/0?q=cats",
The following worked perfectly for me!
var https = require("https");
var options = {
protocol:"https:",
host:"api.imgur.com",
path:"/3/gallery/search/top/all/0?q=cats",
headers:{"Authorization" : "Client-ID {YOUR_ID}"}
}
var req = https.request(options, function(response) {
var str = '';
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
console.log(JSON.parse(str));
});
});
req.end();