string result = string.Empty; //build the request object HttpWebRequest request = (HttpWebRequest)WebRequest.Create(txtRequestURL.Text); if (chkRequestHeader.Checked) { request.Headers.Add("x-api-key", "49b05a5d-36c6-4ed4-98bf-720c2a3414e4"); } request.ContentType = @"application/json"; request.Accept = @"application/json"; request.Method = "POST"; //write the input data (aka post) to a byte array byte[] requestBytes = new ASCIIEncoding().GetBytes(txtReq.Text); //get the request stream to write the post to Stream requestStream = request.GetRequestStream(); //write the post to the request stream requestStream.Write(requestBytes, 0, requestBytes.Length); txtLog.Text += "test_http()-process 6 Reached" + Environment.NewLine; //build a response object to hold the response //submit the request by calling get response HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //get the response stream to read the response from Stream responseStream = response.GetResponseStream(); //now read it out to our result using (StreamReader rdr = new StreamReader(responseStream)) { //set the result to the contents of the stream txtResponse.Text = rdr.ReadToEnd(); }
txtRequestURL.Text
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)