private string POST(string callName, string callPrefix, BaseParams parameters) { // callMethod, callPrefix, ... params Uri address = new Uri(_requestUri + callPrefix + "/" + callName); HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(address); wreq.Method = WebRequestMethods.Http.Post; wreq.ContentType = "application/x-www-form-urlencoded"; wreq.Headers.Add("Accept-encoding", "gzip,deflate"); wreq.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; StringBuilder d = new StringBuilder(); d.Append("apikey=").Append(_apiKey).Append(parameters.getParameterString()); parameters.ResetBaseParams(); byte[] bd = Encoding.UTF8.GetBytes(d.ToString()); wreq.ContentLength = bd.Length; using (Stream ps = wreq.GetRequestStream()) { ps.Write(bd, 0, bd.Length); } return DoRequest(wreq, parameters.OutputMode); }
private string GET(string callName, string callPrefix, BaseParams parameters) { // callMethod, callPrefix, ... params StringBuilder uri = new StringBuilder(); uri.Append(_requestUri).Append(callPrefix).Append("/").Append(callName); uri.Append("?apikey=").Append(_apiKey).Append(parameters.getParameterString()); parameters.ResetBaseParams(); Uri address = new Uri(uri.ToString()); HttpWebRequest wreq = (HttpWebRequest) WebRequest.Create(address); wreq.Method = "GET"; return DoRequest(wreq, parameters.OutputMode); }