public string Post_WebRequest(GlobusGooglePlusLib.Authentication.oAuthToken.Method method, string url, string postData, string[] HeaderName, string[] Value) { HttpWebRequest webRequest = null; StreamWriter requestWriter = null; string responseData = ""; webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest; webRequest.Method = method.ToString(); webRequest.ServicePoint.Expect100Continue = false; //webRequest.UserAgent = "Identify your application please."; //webRequest.Timeout = 20000; for (int i = 0; i < HeaderName.Length; i++) { webRequest.Headers.Add(HeaderName[i], Value[i]); } if (method == GlobusGooglePlusLib.Authentication.oAuthToken.Method.POST) { webRequest.ContentType = "application/json"; //POST the data. requestWriter = new StreamWriter(webRequest.GetRequestStream()); try { requestWriter.Write(postData); } catch { throw; } finally { requestWriter.Close(); requestWriter = null; } } responseData = WebResponseGet(webRequest); webRequest = null; return(responseData); }
public string WebRequest(GlobusGooglePlusLib.Authentication.oAuthToken.Method method, string url, string postData) { HttpWebRequest webRequest = null; StreamWriter requestWriter = null; string responseData = ""; webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest; webRequest.Method = method.ToString(); webRequest.ServicePoint.Expect100Continue = false; //webRequest.UserAgent = "Identify your application please."; //webRequest.Timeout = 20000; if (method == GlobusGooglePlusLib.Authentication.oAuthToken.Method.POST) { webRequest.ContentType = "application/x-www-form-urlencoded"; //POST the data. requestWriter = new StreamWriter(webRequest.GetRequestStream()); try { requestWriter.Write(postData); } catch { throw; } finally { requestWriter.Close(); requestWriter = null; } } responseData = WebResponseGet(webRequest); webRequest = null; return(responseData); }