开发者社区> 问答> 正文

新增部门名为中文时,返回系统繁忙

C#  code  
public static string Addparty()
        {
            HttpWebRequest request = WebRequest.Create("https://oapi.dingtalk.com/department/create?access_token=[    post]") as HttpWebRequest;

            string ps = "{\"name\":\"测试\",\"parentid\":\"1\",\"order\":\"1\"}";

            request.Method = "POST";

            request.ContentType = "application/json";

            //request.ContentLength = Encoding.UTF8.GetByteCount(ps);

            Stream strs = request.GetRequestStream();

            StreamWriter strw = new StreamWriter(strs, Encoding.Default);

            byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(ps);

            strw.Write(requestBytes);

            strw.Close();    


            HttpWebResponse reponse = request.GetResponse() as HttpWebResponse;

            Stream sts = reponse.GetResponseStream();

            StreamReader sr = new StreamReader(sts, Encoding.GetEncoding("UTF-8"));

            string s = sr.ReadToEnd();

            sr.Close();
            sts.Close();
            return s;
        }

展开
收起
neoamell 2015-08-04 11:39:02 5343 0
1 条回答
写回答
取消 提交回答
  • Re新增部门名为中文时,返回系统繁忙
    系统真的很忙
    2015-08-11 22:19:15
    赞同 展开评论 打赏
问答分类:
C#
问答地址:
问答排行榜
最热
最新

相关电子书

更多
《用管控策略设定多账号组织全局访问边界》 立即下载
软件定义的数据智能 立即下载
分析型数据库标准发展与行业观察 立即下载