Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i am trying to send the HTTP post request please find below :

VB
http://test.p-44.com/xml/pickup.xml?p44Login=DEMO&p44Password=DEMO&xml=<dispatchrequest><vendorcode>CODE</vendorcode> ... (rest of dispatch request xml) ... </dispatchrequest>

when i am trying to process the above request every time i got web exception will you please help me on this.

sample code :

Dim WebRequest As HttpWebRequest = CType(HttpWebRequest.Create("https://test.p-44.com/xml/pickup.xml"), HttpWebRequest)
          
          WebRequest.AllowAutoRedirect = False
          WebRequest.Method = "POST";
          WebRequest.ContentType = "text/xml"
         Dim requestStream As Stream = WebRequest.GetRequestStream()
         Dim Somebyte() As Byte = Encoding.UTF8.GetBytes(requstXML)
         requestStream.Write(Somebyte, 0, Somebyte.Length)
         requestStream.Close()

         Dim myResponseFDX As HttpWebResponse = CType(WebRequest.GetResponse(), HttpWebResponse)


What I have tried:

Hi i am trying to send the HTTP post request please find above i've describe the problem.
Posted
Updated 3-Jul-16 22:49pm
v2

1 solution

C#
using System.Net;
using System.Text;  // for class Encoding
POST

var request = (HttpWebRequest)WebRequest.Create("http://www.example.com/recepticle.aspx");

var postData = "thing1=hello";
    postData += "&thing2=world";
var data = Encoding.ASCII.GetBytes(postData);

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;

using (var stream = request.GetRequestStream())
{
    stream.Write(data, 0, data.Length);
}

var response = (HttpWebResponse)request.GetResponse();

var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
GET

var request = (HttpWebRequest)WebRequest.Create("http://www.example.com/recepticle.aspx");

var response = (HttpWebResponse)request.GetResponse();

var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900