zoukankan      html  css  js  c++  java
  • 发起post请求

      

    string postUrl = "https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo";
    //string requestStr= Utils.DCUtils.HttpPost(postUrl,HttpUtility.UrlEncode(requestXml));
    //string requestStr = Utils.DCUtils.HttpPost(postUrl,"xml="+requestXml);

    #region 发起post请求
    HttpWebRequest webrequest = (HttpWebRequest)HttpWebRequest.Create(postUrl);
    //webrequest.ClientCertificates.Add(cer);
    webrequest.Method = "post";

    byte[] postdatabyte = Encoding.UTF8.GetBytes(requestXml);
    webrequest.ContentLength = postdatabyte.Length;
    Stream stream;
    stream = webrequest.GetRequestStream();
    stream.Write(postdatabyte, 0, postdatabyte.Length);
    stream.Close();

    HttpWebResponse httpWebResponse = (HttpWebResponse)webrequest.GetResponse();
    StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
    string requestStr = streamReader.ReadToEnd();
    #endregion

  • 相关阅读:
    01-发送你的第一个请求
    postman使用
    java poi导出多sheet页
    base64加密解密
    Django crontab
    super().__init__()
    paramiko模块
    列表转json数据返回
    socket模块判断ip加端口的连通性
    登录拦截器
  • 原文地址:https://www.cnblogs.com/james641/p/4980517.html
Copyright © 2011-2022 走看看