0
var values = new NameValueCollection
{
    { "key", "key_edited_for_security" },
    { "image", Convert.ToBase64String(ms.ToArray()) }
};

byte[] response = w.UploadValues("https://api.imgur.com/2/upload.xml", values);

This is working just fine, the key was from another stackoverflow post that someone created a few years ago, (Uploading to imgur.com), I've registered my application at imgur here but when I use my client id or client secret id I get error 400 (bad request).

Community
  • 1
  • 1
Levi H
  • 3,426
  • 7
  • 30
  • 43

1 Answers1

0

I did tested the code above, seems to be working fine

    static void Main(string[] args)
    {

        WebClient client = new WebClient();
        NameValueCollection values = new NameValueCollection();
        values["image"] = Convert.ToBase64String(File.ReadAllBytes(@"C:\test.jpg"));
        values["key"] = "the_key";
        byte[] responseBytes = client.UploadValues("https://api.imgur.com/2/upload.xml", values);
        string response = Encoding.Default.GetString(responseBytes);
        client.Dispose();
        /* Content of response 
        <?xml version="1.0" encoding="utf-8"?>
        <upload><image><name/><title/><caption/><hash>E63BcFm</hash><deletehash>zWO2xnca2co0VcB</deletehash><datetime>2013-02-15 23:15:45</datetime><type>image/jpeg</type><animated>false</animated><width>677</width><height>342</height><size>29513</size><views>0</views><bandwidth>0</bandwidth></image><links><original>http://i.imgur.com/E63BcFm.jpg</original><imgur_page>http://imgur.com/E63BcFm</imgur_page><delete_page>http://imgur.com/delete/zWO2xnca2co0VcB</delete_page><small_square>http://i.imgur.com/E63BcFms.jpg</small_square><large_thumbnail>http://i.imgur.com/E63BcFml.jpg</large_thumbnail></links></upload>
        */
    }
Parimal Raj
  • 20,189
  • 9
  • 73
  • 110