Files
U8-Import/U8AppMain/HttpHelper.cs
2020-12-18 13:51:58 +08:00

28 lines
882 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace U8AppMain
{
public static class HttpHelper
{
public static Task<string> Post(string url, string strBody)
{
strBody = strBody ?? "";
using (HttpClient client = new HttpClient())
{
var httpContent = new StringContent(strBody, Encoding.UTF8);
httpContent.Headers.ContentType.MediaType = "application/xml";
httpContent.Headers.ContentType.CharSet = "utf-8";
HttpResponseMessage response = client.PostAsync(url, httpContent).Result;
if (httpContent != null)
httpContent.Dispose();
return response.Content.ReadAsStringAsync();
}
}
}
}