UTF8Encoding encoding = new UTF8Encoding();
var json = "{\"CompanyID\":\"hk\" ," +
"\"Items\":[{ \"DNDH\":\"DNDH\" , \"pono\":\"123\",\"itemno\":\"123\" }," +
"{ \"DNDH\":\"12345\" , \"pono\":\"pono\",\"itemno\":\"123\" }]}";
byte[] data = encoding.GetBytes(json);
// Prepare web request...
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "POST";
myRequest.ContentType = "application/json";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
try
{
// Get response
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();
}
catch (Exception ex)
{
}
C#_Post
最新推荐文章于 2022-04-28 19:37:18 发布