I'm trying to create a simple Imgur app that will upload images to their server via a WebClient.UploadValues() call. I found this code elsewhere in StackOverflow:
public static void PostToImgur(string ImageFilePath)
{
using (var w = new WebClient())
{
var values = new NameValueCollection
{
{ "key", API_KEY },
{ "image", Convert.ToBase64String(File.ReadAllBytes(ImageFilePath)) }
};
byte[] response = w.UploadValues("http://imgur.com/api/upload.xml", values);
XDocument result = (XDocument.Load(new MemoryStream(response)));
}
}
I inserted a breakpoint on the line which returns the WebClient response, however it seems to skip it completely without throwing any exceptions or anything. This is not anything I've ever seen before in Visual Studio, so something leads me to believe that there may be something strange happening.
If it helps, I'm running this in a Windows 7 virtual machine in OSX. Anybody have any ideas why this may be happening?
Found the issue, I was using an OAuth token to pass to Imgur, where this method is used to upload with the Anonymous API.
Getting a new API key for an anonymous application solved it.