0

I have a string with 300 rows, there is a way to do it POST? Here is my code, is currently working on a limited amount of short letters:

WebRequest req = (HttpWebRequest)WebRequest.Create(
    "http://thisisurl/test.php?ad=test&f=" + information_data);
req.Method = "POST";
WebResponse res = req.GetResponse();
Mike Cluck
  • 31,869
  • 13
  • 80
  • 91
  • 2
    You're not using the f parameter to post data are you? – Joe Phillips Aug 06 '14 at 16:47
  • f parameter its for post data –  Aug 06 '14 at 17:00
  • @user3915278 it is not *POSTing*. *POSTing* means, you write the data to the body of the Http message. (BTW: url has a length limitation. this is why you can't *"post"* a long data) – L.B Aug 06 '14 at 17:13
  • Ideal solution would be posting data as byte array. check this http://www.hanselman.com/blog/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx http://technet.rapaport.com/info/lotupload/samplecode/full_example.aspx – Deepu Madhusoodanan Aug 06 '14 at 17:26

1 Answers1

1

I'm going to explain your problem right now and go ahead and give you a possible solution at the end.

You are hitting the character limit for url length / query parameter length. IE limits it as low as 2,083.

The data you are providing should be sent in the body of the http request, not the URL parameters.

A Post Request Normally is done in the following format(Code from the link).

using (var wb = new WebClient())
{
    var data = new NameValueCollection();
    data["username"] = "myUser";
    data["password"] = "myPassword";

    var response = wb.UploadValues(url, "POST", data);
}

This thread should have enough info if you want to use the WebRequest class instead: HTTP request with post

Community
  • 1
  • 1
Alfredo Alvarez
  • 336
  • 3
  • 15