[HttpPost] public HttpResponseMessage InsertPatDet([FromBody]List<Patient> pt) {}
<pre>//Create a request using a URL that can receive a post. string url = "https://url"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Method = "POST"; // Create POST data and convert it to a byte array. string postData = GetJSonData();// "{\"name\":\"Here is the json text byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest. request.ContentType = "application/x-www-form-urlencoded"; //request.ContentType = "application/json; charset=utf-8 "; request.Accept = "application/json"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. //List<byte> ListByte = new List<Byte>(byteArray); dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); // Get the response. WebResponse response = request.GetResponse(); // Display the status. Response.Write(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Display the content. Response.Write(responseFromServer); // Clean up the streams. reader.Close(); dataStream.Close(); response.Close();
Quote: C# request.ContentType = "application/x-www-form-urlencoded";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentType = "application/json";
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)