Imgur API version 3 uploading C#

1,524 views
Skip to first unread message

elgh...@gmail.com

unread,
Apr 30, 2013, 8:48:42 AM4/30/13
to im...@googlegroups.com
I'm trying to use imgur api 3 to upload images with C#
Any help

yemil....@gmail.com

unread,
May 13, 2013, 3:33:08 AM5/13/13
to im...@googlegroups.com
had this same issue, nobody helped me, figured it out, thought i'd help you.


using (var w = new WebClient())
{
var values = new NameValueCollection
{
{"image", Convert.ToBase64String(File.ReadAllBytes(xOut))}
};

w.Headers.Add("Authorization", "Client-ID xxxxxxxxxxxxx");
byte[] response = w.UploadValues("https://api.imgur.com/3/upload.xml", values);
}

replace xxxxxxxxx with your client id, given to you by imgur (must register your app first, even to upload anonymously). the biggest problem for me was I could not figure out how to send that "header" value since none of the code samples I found before had this. well, now we know. my program is now uploading quickly and getting a response (byte[]). process that however you may need, I just parse it for the link. there may be easier, cleaner ways (would love to hear it) but this works :-)

adamell

unread,
Jun 5, 2013, 2:38:07 PM6/5/13
to im...@googlegroups.com

karlt...@gmail.com

unread,
Jun 24, 2013, 4:16:56 PM6/24/13
to im...@googlegroups.com
Hi,

Thank you for that code! I have never used an API before so I was struggling with being able to upload to Imgur.

After spending some time figuring it out I have converted your code to Visual Basic so that I can use it in my program but I am struggling with how to process/parse the response. When I use .ToString or Convert.ToBase64String or BitConverter.ToString I get a seemingly random set of characters. Would you be able to show me your method of converting it to a link?
If you do not know Visual Basic I would be happy to see it in C# and try and convert it again.

Thank you for your time

radko...@gmail.com

unread,
Oct 25, 2013, 4:56:18 AM10/25/13
to im...@googlegroups.com
Thank You!
Reply all
Reply to author
Forward
0 new messages