数据POST操作

2018-06-22 07:58:15来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

  WXUserPara wxpara = new WXUserPara();
                wxpara.userid = o.LoginName;//成员ID对应客户端账号
                wxpara.name = o.Name;//成员名称
                wxpara.mobile = o.MobilePin;//手机号码
                wxpara.department = (int)EOQuestionLogic.GetWxGetList(o.DefaultDepartmentID).Tables[0].Rows[0]["wx_department_id"];
                wxpara.order = (int)o.OrderNum;//排序
                wxpara.gender = 1;//性别默认男
                wxpara.email = o.Email;//邮箱
                /*业务系统人员配置增加职务,*/
                if (!string.IsNullOrEmpty(txtDuty.Text))
                {
                    wxpara.position = txtDuty.Text;
                }
 string json = JsonConvert.SerializeObject(wxpara);
//调用webAPI接口,post数据到企业微信中
                string ss = HttpPost("http://XXX/eo/wxapi/api/EO/updateUser", json);

 public static string HttpPost(string url, string body)
        {
            Encoding encoding = Encoding.UTF8;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "POST";
            request.Accept = "text/html, application/xhtml+xml, */*";
            request.ContentType = "application/json";

            byte[] buffer = encoding.GetBytes(body);
            request.ContentLength = buffer.Length;
            request.GetRequestStream().Write(buffer, 0, buffer.Length);
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                return reader.ReadToEnd();
            }
        }
public class WXUserPara
        {
            /// <summary>
            /// 成员UserID  
            /// </summary>
            public string userid { get; set; }
            /// <summary>
            /// 成员名称
            /// </summary>
            public string name { get; set; }
            /// <summary>
            /// 英文名
            /// </summary>
            public string english_name { get; set; }
            /// <summary>
            /// 手机号码
            /// </summary>
            public string mobile { get; set; }
            /// <summary>
            /// 微信部门ID
            /// </summary>
            public int department { get; set; }
            /// <summary>
            /// 排序
            /// </summary>
            public int order { get; set; }
            /// <summary>
            /// 职位信息
            /// </summary>
            public string position { get; set; }
            /// <summary>
            /// 性别
            /// </summary>
            public int gender { get; set; }
            /// <summary>
            /// 邮箱
            /// </summary>
            public string email { get; set; }
            /// <summary>
            /// 座机
            /// </summary>
            public string telephone { get; set; }
            /// <summary>
            /// 上级字段
            /// </summary>
            public string isleader { get; set; }
            /// <summary>
            /// 成员头像的mediaid
            /// </summary>
            public string avatar_mediaid { get; set; }
            /// <summary>
            /// 启用
            /// </summary>
            public int enable { get; set; }
            /// <summary>
            /// 自定义字段
            /// </summary>
            public string extattr { get; set; }
            /// <summary>
            /// 成员对外属性
            /// </summary>
            public string ternal_profile { get; set; }
        }

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:服务端JSON内容中有富文本时

下一篇:js获取select下拉框的value值和text文本值