Click here to Skip to main content
15,915,611 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have tried to upload images on imgur.com using this code below
It works for few times but it returns 429 error- too many requests
Is it possible to upload images from other url on imgur progrmmatically using c#?

private string upload_img_from_url(string old_img_url)
{

string new_img_url = "";

string key = "<<<my key="" is="" here="">>>";

try
{
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Client-ID " + key);
string response = client.DownloadString("http://imgur.com/upload?url=" + old_img_url);

response = response.Substring(response.IndexOf("<link rel=\"image_src\""), response.IndexOf("


string str_href = "href=\"(.*)\"";
Match match = Regex.Match(response, str_href);
if (match.Success)
{
new_img_url = match.Groups[1].Value;

}
}
}
catch (Exception ex)
{
txt_ssulf_error.Text = ex.Message;
}

return new_img_url;
}

What I have tried:

I have tried to upload using old api version
the url was http://imgur.com/api/upload?url=<<the image url>>
But it returns 404 error
Posted
Updated 10-Apr-16 2:24am
Comments
Richard MacCutchan 10-Apr-16 7:59am    
This is a question for imgur, nothing to do with programming.
hapiten 10-Apr-16 8:09am    
oh i see thank you

1 solution

Look at the error message:
429 error - too many requests
It's pretty clear that you are posting faster than the site will allow you to.
Either slow down your post rate to a level they will accept, or talk to the site technical support and ask them what to do about it.
Either way, this isn't a problem we can solve for you!
 
Share this answer
 
Comments
hapiten 10-Apr-16 9:32am    
Thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900