public string SubmitPOST() { ASCIIEncoding encoding = new ASCIIEncoding(); byte[] data = encoding.GetBytes("FirstName=John&LastName=Doe&Email=noemail@leads.com"); string deliveryAddress = "https://leads.leadexec.net/processor/insert/general"; HttpWebRequest RequestObj = (HttpWebRequest)WebRequest.Create(deliveryAddress); RequestObj.Method = "POST"; RequestObj.ContentType = "application/x-www-form-urlencoded"; RequestObj.ContentLength = data.Length; Stream RequestStream = RequestObj.GetRequestStream(); RequestStream.Write(data, 0, data.Length); RequestStream.Close(); HttpWebResponse HttpResponse; HttpResponse = (HttpWebResponse)RequestObj.GetResponse(); Stream streamResponse = HttpResponse.GetResponseStream(); StreamReader streamRead = new StreamReader(streamResponse); return streamRead.ReadToEnd(); }In the example above, the example POST string is first encoded and then is sent through the request stream to the POST URL. The response is then received and would then be processed to determined the desired action depending on the sending page's requirements and method sent to.
Copyright ©2024 ClickPoint Software