Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 544093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:37:05+00:00 2026-05-13T10:37:05+00:00

Imgur is a image uploading website who offers an API to upload My code

  • 0

Imgur is a image uploading website who offers an API to upload

My code looks exactly like the PHP code they provide as an example. however, in their php code they are http_build_query($pvars);

It seems like they are URLEncoding their query before posting it. edit: Note that I have changed to full .NET 3.5 rather then the client profile. This gave me access to system.web so I used httputliity.urlencode(). This made the api return a “fail” with a “no image was sent”. If I don’t encode then the API returns an “okay” with a link to the picture, however no picture is uploaded (like a blank file).

How can I fix my code to work properly against their API?

 Image image = Image.FromFile("C:\\Users\\Affan\\Pictures\\1509310.jpg");
        MemoryStream ms = new MemoryStream();
        // Convert Image to byte[]
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        byte[] imageBytes = ms.ToArray();

        WebRequest wb = WebRequest.Create(new Uri("http://imgur.com/api/upload.xml"));
        wb.ContentType = "application/x-www-form-urlencoded";            
        wb.Method = "POST";
        wb.Timeout = 10000;
        Console.WriteLine(imageBytes.Length);
        string parameters = "key=433a1bf4743dd8d7845629b95b5ca1b4&image=" + Convert.ToBase64String(imageBytes);


        Console.WriteLine("parameters: " + parameters.Length);
        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
        byte[] bytes = encoding.GetBytes(parameters);
        // byte[] bytes = Convert.FromBase64String(parameters);

        System.IO.Stream os = null;
        try { // send the Post
            wb.ContentLength = bytes.Length;   //Count bytes to send
            os = wb.GetRequestStream();               
            os.Write(bytes, 0, bytes.Length);         //Send it
        } catch (WebException ex) {
            MessageBox.Show(ex.Message, "HttpPost: Request error");
            Console.WriteLine(ex.Message);
        } finally {
            if (os != null) {
               // os.Close();
            }
        }

        try { // get the response
            WebResponse webResponse = wb.GetResponse();

            StreamReader sr = new StreamReader(webResponse.GetResponseStream());
            //MessageBox.Show(sr.ReadToEnd().Trim());
            Console.WriteLine(sr.ReadToEnd().Trim());
        } catch (WebException ex) {
            MessageBox.Show(ex.Message, "HttpPost: Response error");
        }       
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:37:06+00:00Added an answer on May 13, 2026 at 10:37 am

    I’ve just uploaded this image

    Hello World

    using this code:

    using (var w = new WebClient())
    {
        var values = new NameValueCollection
        {
            { "key", "433a1bf4743dd8d7845629b95b5ca1b4" },
            { "image", Convert.ToBase64String(File.ReadAllBytes(@"hello.png")) }
        };
    
        byte[] response = w.UploadValues("http://imgur.com/api/upload.xml", values);
    
        Console.WriteLine(XDocument.Load(new MemoryStream(response)));
    }
    

    You might want to change your API key now 🙂

    The output was:

    <rsp stat="ok">
      <image_hash>IWg2O</image_hash>
      <delete_hash>fQAXiR2Fdq</delete_hash>
      <original_image>http://i.imgur.com/IWg2O.png</original_image>
      <large_thumbnail>http://i.imgur.com/IWg2Ol.jpg</large_thumbnail>
      <small_thumbnail>http://i.imgur.com/IWg2Os.jpg</small_thumbnail>
      <imgur_page>http://imgur.com/IWg2O</imgur_page>
      <delete_page>http://imgur.com/delete/fQAXiR2Fdq</delete_page>
    </rsp>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The answer is: I missed the fact that there was… May 16, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer Drop a echo mysql_num_rows($result); immediately after the mysql_query line, and… May 16, 2026 at 12:33 pm
  • Editorial Team
    Editorial Team added an answer Use the built-in MVC URL helper like so: <script src="<%=… May 16, 2026 at 12:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I just recieve my unique developer API key from Imgur and I'm aching to
Here is the working code in Python (using cURL): #!/usr/bin/python import pycurl c =
<rsp stat=ok> <image_hash>ducex</image_hash> <delete_hash>QXHbCECmDX</delete_hash> <original_image>http://i.imgur.com/ducex.jpg</original_image> <large_thumbnail>http://i.imgur.com/ducexl.jpg</large_thumbnail> <small_thumbnail>http://i.imgur.com/ducexs.jpg</small_thumbnail> <imgur_page>http://imgur.com/ducex</imgur_page> <delete_page>http://imgur.com/delete/QXHbCECmDX</delete_page> </rsp> First off all, can
See: http://i.imgur.com/pQNQh.png Somehow I made this happen and I don't know how to undo
I want to show an image from an URL with a certain width and
I have a div that contains 3 fields You can see the image here
The text 'Step 1' is not centering on the image no matter what I
<?xml version=1.0 encoding=utf-8?> <rsp stat=ok> <image_hash>cxmHM</image_hash> <delete_hash>NNy6VNpiAA</delete_hash> <original_image>http://imgur.com/cxmHM.png</original_image> <large_thumbnail>http://imgur.com/cxmHMl.png</large_thumbnail> <small_thumbnail>http://imgur.com/cxmHMl.png</small_thumbnail> <imgur_page>http://imgur.com/cxmHM</imgur_page> <delete_page>http://imgur.com/delete/NNy6VNpiAA</delete_page> </rsp> This
I've been struggling for quite a while to get this feature working: I want
I think I've found the cause: Document Info window in IB has a warning:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.