请求地址:/v5/Contracts/positionSign.json
请求方式:POST
接口版本: 5.2.3
接口描述:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | using System; using System.Text; using System.IO; using System.Net; using System.Web; namespace APIStore { class HttpRequest { /* * HTTP的Post请求方式(推荐) * strUrl 请求地址 * param 请求数据 */ public string requestPost( string strUrl, string param) { HttpWebRequest httpWebRequest = WebRequest.Create(strUrl) as HttpWebRequest; httpWebRequest.Method = "POST" ; //指定允许数据发送的请求的一个协议方法 httpWebRequest.ContentType = "application/x-www-form-urlencoded" ; //设置 ContentType 属性设置为适当的值 httpWebRequest.Headers.Add( "appId" , "你的appId" ); httpWebRequest.Headers.Add( "appKey" , "你的appKey" ); httpWebRequest.Headers.Add( "version" , "5.2.3" ); byte [] data = Encoding.UTF8.GetBytes(param); using (Stream stream = httpWebRequest.GetRequestStream()) { stream.Write(data, 0, data.Length); //写入数据 } WebResponse webResponse = httpWebRequest.GetResponse() as HttpWebResponse; //发起请求,得到返回对象 Stream dataStream = webResponse.GetResponseStream(); StreamReader reader = new StreamReader(dataStream, Encoding.UTF8); string returnStr = reader.ReadToEnd(); // Clean up the streams and the response. reader.Close(); webResponse.Close(); return returnStr; } /** * 获取内容 */ public void getContent() { string url= "https://api-v2.1dq.com/v5/Contracts/positionSign.json" string param="easy_id=175592531139104768&position=[ { "x" : "200" , "y" : "200" , "page" : "第几页" , "seal_type" : "1、普通印章,2、骑缝章" , "user_type" : "类型,1为个人,2为企业" , "seal_width" : "无特殊要求,不用传递,为空默认即可。签署区域宽度" , "seal_height" : "无特殊要求,不用传递,为空默认即可。签署区域高度" , "area_title" : "无特殊要求,不用传递,为空默认即可。签署提示" , "page_width" : "无特殊要求,不用传递,为空默认即可。指定页面宽度" , "sign_id" : "无特殊要求,不用传递,为空默认即可。签署人或填写人id" } ]&words_id=&number=test@1dq.com" string returnStr = null ; returnStr = "post result:" + this .requestPost(url, param); Console.WriteLine(returnStr); } } } |