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

  • SEARCH
  • Home
  • 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 5842423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:00:58+00:00 2026-05-22T12:00:58+00:00

I am working on an API kind of project, I have wrote a WebMethod

  • 0

I am working on an API kind of project,

I have wrote a WebMethod (not exactly. I am using MVC to create REST like API)

public UploadFileImage(string employeeId, byte[] imageBytes, string imageName)
{
    // saves the imagebyte as an image to a folder
}

the web service would be consumed by a web app, or windows or even iphone or such portable stuffs. I am testing my web service using a web app, by simple httpPost.

string Post(Uri RequestUri, string Data)
    {
        try
        {
            HttpWebRequest request = HttpWebRequest.Create(RequestUri) as HttpWebRequest;

            request.Method = "POST";

            request.ContentType = IsXml.Checked ? "text/xml" : "application/x-www-form-urlencoded";

            byte[] bytes = Encoding.ASCII.GetBytes(Data);
            Stream os = null; // send the Post
            request.ContentLength = bytes.Length;   //Count bytes to send
            os = request.GetRequestStream();
            os.Write(bytes, 0, bytes.Length);

            HttpWebResponse httpWebResponse = (HttpWebResponse)request.GetResponse();
            StreamReader streamReader = new StreamReader(request.GetResponse().GetResponseStream());
            return streamReader.ReadToEnd();

        }
        catch (Exception ex)
        {
            return ex.Message;
        }
    }

This code works fine for evey method like, AddEmployee, DeleteEmployee etc. THe parameter Data is of form “Id=123&name=abcdefgh&desig=Developer”,

How I call any other function is
Post(new Uri(“http://localhost/addemployee”),”name=abcd&password=efgh”)
where post is the function i wrote.

All good for all functions. Except that I dont know how to consume the above mentioned function UploadFileImage to upload an image?

Thanks

  • 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-22T12:00:58+00:00Added an answer on May 22, 2026 at 12:00 pm

    Try encoding the imageBytes as Base64.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project and I need to create an API. I am
I am working on a PHP REST API. I would like require a user
I've been working with the SpiderMonkey C API and would like to implement a
I'm working on a REST API. The key objects ("nouns") are "items", and each
I just started working using Google Maps API yesterday, and trying to set up
I am working on web project. We are using flex as UI layer. My
I have a question regarding map api. I was using the the google map
We are using HttpURLConnection API to invoke a REST API to the same provider
I have 2 questions to ask regarding opening files (any kind of files) using
Qt 4.7 DOM API seems kind of strange :(. I have a text HTML

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.