private string POST(string callName, string callPrefix, AlchemyAPI_BaseParams parameters) { // callMethod, callPrefix, ... params var address = new Uri(_requestUri + callPrefix + "/" + callName); var wreq = WebRequest.Create(address) as HttpWebRequest; wreq.Proxy = null; wreq.Method = "POST"; wreq.ContentType = "application/x-www-form-urlencoded"; var 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.getOutputMode())); }
private string GET(string callName, string callPrefix, AlchemyAPI_BaseParams parameters) { // callMethod, callPrefix, ... params var uri = new StringBuilder(); uri.Append(_requestUri).Append(callPrefix).Append("/").Append(callName); uri.Append("?apikey=").Append(_apiKey).Append(parameters.getParameterString()); parameters.resetBaseParams(); var address = new Uri(uri.ToString()); var wreq = WebRequest.Create(address) as HttpWebRequest; wreq.Proxy = null; byte[] postData = parameters.GetPostData(); if (postData == null) { wreq.Method = "GET"; } else { wreq.Method = "POST"; using (Stream ps = wreq.GetRequestStream()) { ps.Write(postData, 0, postData.Length); } } return(DoRequest(wreq, parameters.getOutputMode())); }
private string POST(string callName, string callPrefix, AlchemyAPI_BaseParams parameters) { // callMethod, callPrefix, ... params var address = new Uri(_requestUri + callPrefix + "/" + callName); var wreq = WebRequest.Create(address) as HttpWebRequest; wreq.Proxy = null; wreq.Method = "POST"; wreq.ContentType = "application/x-www-form-urlencoded"; var 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.getOutputMode()); }
private string GET(string callName, string callPrefix, AlchemyAPI_BaseParams parameters) { // callMethod, callPrefix, ... params var uri = new StringBuilder(); uri.Append(_requestUri).Append(callPrefix).Append("/").Append(callName); uri.Append("?apikey=").Append(_apiKey).Append(parameters.getParameterString()); parameters.resetBaseParams(); var address = new Uri(uri.ToString()); var wreq = WebRequest.Create(address) as HttpWebRequest; wreq.Proxy = null; byte[] postData = parameters.GetPostData(); if (postData == null) { wreq.Method = "GET"; } else { wreq.Method = "POST"; using (Stream ps = wreq.GetRequestStream()) { ps.Write(postData, 0, postData.Length); } } return DoRequest(wreq, parameters.getOutputMode()); }