WebRequest CreateRequest(string method, string url, Dictionary <string, string> parameters) { string encodedParams = PercentageEncoding.EncodeParameters(parameters); WebRequest request; if (method == "GET") { request = WebRequest.Create(string.Format("{0}?{1}", url, encodedParams)); } else { request = WebRequest.Create(url); } request.Method = method; request.ContentType = "application/x-www-form-urlencoded"; request.Headers.Add("Authorization", MakeOAuthHeader(method, url, parameters)); if (method == "POST") { byte[] postBody = new ASCIIEncoding().GetBytes(encodedParams); using (Stream stream = request.GetRequestStream()) { stream.Write(postBody, 0, postBody.Length); } } return(request); }
private string SearchPost(Dictionary <string, string> parameters) { string encodedParams = PercentageEncoding.EncodeParameters(parameters); string fullURL = string.Format("{0}?{1}", ApiPoint.Google_Search_Activites, encodedParams); APIInvoker.FetchRest fetchRest = new APIInvoker.FetchRest(); fetchRest.Method = "GET"; string jsonResult = fetchRest.GetData(fullURL, string.Empty); return(jsonResult); }