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 8073561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:22:23+00:00 2026-06-05T14:22:23+00:00

Why I am not able to send POST request using the following command and

  • 0

Why I am not able to send POST request using the following command and some other code similar to it. Where as when I send same request using Mozilla browser’s RESTClient it works fine. This is only for a server’s simulator deployed on LAN/even on my local machine. with Live server it is working fine.

ASCIIEncoding encoding = new ASCIIEncoding();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://192.168.220.12:5000"); // this is my system's local ip
byte[] byteArray = encoding.GetBytes("hello");
request.Method = "POST";
request.ContentType = "text/xml";// i tried it with "application/x-www-form-urlencoded" as well
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Flush();
dataStream.Close();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
Console.ReadKey();
reader.Close();
dataStream.Close();
response.Close();

By testing it on server, I saw there is a message for successful receiving of the request but it does not show the data received from the above code whereas it shows the data from RESTclient.

What could be the possible reason. Is there any firewall the is not allowing to send postdata from .net library to simulator?

This is the same response for un formatted xml, I don’t see anything wrong with the xml (same copy of what I am sending through RESTclient).

  • 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-06-05T14:22:24+00:00Added an answer on June 5, 2026 at 2:22 pm

    It is not clear what content type does the server expects the request to be. If it is application/x-www-form-urlencoded (key=value pairs) you could simplify your code:

    using (var client = new WebClient())
    {
        var values = new NameValueCollection
        {
            { "key1", "value1" },
            { "key2", "value2" },
        };
        byte[] result = client.UploadValues("http://192.168.220.12:5000", values);
        string resultStr = Encoding.Default.GetString(result);
        ...
    }
    

    If you want to POST XML then:

    using (var client = new WebClient())
    {
        client.Headers[HttpRequestHeader.ContentType] = "text/xml";
        string xml = "<foo>Bar</foo>";
        string result = client.UploadString("http://192.168.220.12:5000", xml);
    }
    

    So as you can see, it will all depend on what does your server side script expects.

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

Sidebar

Related Questions

I am using Ajax POST method to send data, but i am not able
I am not able to send publish message via kaazing javascript AMPQ library. Below
Not able to store all binary data values into sqlite3 table using QT. For
Hi I am not able to capture the screen shot using selenium webdriver .
I am not able to find a similar question else where on this site,
I have a AJAX script which sends a POST request to PHP with some
I would like my android app to be able to send some information to
I'm using a Java program to POST some XML data from a remote client
I have an access token and i want to send the POST request and
I'm trying to send a cURL request from a Windows Server 2008 machine using

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.