public QueryResponseParam <T> Apply <T>(QueryRequestParam param) { string path = GetRestPath(); var qrp = SubmitPostOperation <T>(path, param); return(qrp); }
protected QueryResponseParam <T> SubmitPostOperation <T>(string restPath, QueryRequestParam param) { string payload = JsonConvert.SerializeObject(param); string url = string.Format("{0}{1}", BaseUrl, restPath); string postData = string.Format("JsonContent={0}", payload); byte[] data = Encoding.ASCII.GetBytes(postData); var httpReq = WebRequest.Create(url); httpReq.Method = "POST"; httpReq.ContentType = "application/x-www-form-urlencoded"; httpReq.ContentLength = data.Length; var sr = httpReq.GetRequestStream(); sr.Write(data, 0, data.Length); var response = httpReq.GetResponse(); string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); var qrp = JsonConvert.DeserializeObject <QueryResponseParam <T> >(responseString); return(qrp); }