Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you modify your code to this:</p> <pre><code>public XDocument Upload(string imageAsBase64String) { XDocument result = null; using (var webClient = new WebClient()) { var values = new NameValueCollection { { "key", key }, { "image", imageAsBase64String } }; byte[] response = webClient.UploadValues("http://api.imgur.com/2/upload.xml", "POST", values); result = XDocument.Load(System.Xml.XmlReader.Create(new MemoryStream(response))); } return result; } </code></pre> <p>Everything will work fine with an <strong>ANONYMOUS</strong> API key. To use the authenticated API you will have to create an OAuth token using your Consumer Key and Consumer Secret.</p> <p>Imgur has some more information about the specific endpoints needed and some links to additional help here: <a href="http://api.imgur.com/auth" rel="nofollow">http://api.imgur.com/auth</a></p> <p>Your conversion code looks mostly fine, I have changed it slightly:</p> <pre><code>[HttpPost] public ActionResult UploadImage(HttpPostedFile uploadFile) { if (uploadFile.ContentLength &gt; 0) { var imgService = new ImgUrImageService(); byte[] fileBytes = new byte[uploadFile.ContentLength]; uploadFile.InputStream.Read(fileBytes, 0, fileBytes.Length); uploadFile.InputStream.Close(); string fileContent = Convert.ToBase64String(fileBytes); var response = imgService.Upload(fileContent); } return View(); } </code></pre> <p>In your original upload code you add an extra value of type, are you still adding this or did you switch your code to match my changed code above? I see no reason to add this value and I don't see where it's supported with imgur.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload