标签:
工作经验 备忘
//API接口
using (var Client = new HttpClient()) {
Client.BaseAddress = new Uri("aip地址 比如http://12.0.2.66:8098/");
Client.DefaultRequestHeaders.Accept.Clear();
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
Client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "唯一键");
var apiparcel = new Apiparcel() //Apiparcel类
{
pin = pin, //给类属性赋值
};
response = Client.PostAsJsonAsync("地址", apiparcel).Result; //post提交
//ApiMessage 类
ApiMessage message = response.Content.ReadAsAsync<ApiMessage>().Result; //返回信息
if (response.IsSuccessStatusCode)
{
MessageBox.Show(message.msg);
}
标签:
原文地址:http://www.cnblogs.com/panjuan/p/4499415.html