private Task <HttpResponseMessage> ExecuteRequestJson(ConnectionHelper.WebServiceCallType calltype, string jsonval, string url, string apikey = "") { var uri = new Uri(ConnectionHelper.AppUrl + url); var client = new HttpClient(); if (!string.IsNullOrEmpty(apikey)) { //var byteArray = Encoding.UTF8.GetBytes(apikey); //client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(" ", apikey); client.DefaultRequestHeaders.Add("Autenticate", apikey); } if (calltype == ConnectionHelper.WebServiceCallType.Post) { return(client.PostAsync(uri, new StringContent(jsonval, Encoding.UTF8, "application/json"))); } else if (calltype == ConnectionHelper.WebServiceCallType.Put) { return(client.PutAsync(uri, new StringContent(jsonval, Encoding.UTF8, "application/json"))); } else { return(client.PutAsync(uri, new StringContent(jsonval, Encoding.UTF8, "application/json"))); } }
private Task <HttpResponseMessage> ExecuteRequest(ConnectionHelper.WebServiceCallType calltype, IList <KeyValuePair <string, string> > paramList, string url) { var uri = new Uri(ConnectionHelper.AppUrl + url); var client = new HttpClient(); if (calltype == ConnectionHelper.WebServiceCallType.Post) { return(client.PostAsync(uri, new System.Net.Http.FormUrlEncodedContent(paramList))); } else if (calltype == ConnectionHelper.WebServiceCallType.Put) { return(client.PutAsync(uri, new System.Net.Http.FormUrlEncodedContent(paramList))); } else { client.BaseAddress = new Uri(""); return(client.DeleteAsync(url)); } }
private Task <HttpResponseMessage> ExecuteRequest(ConnectionHelper.WebServiceCallType calltype, IList <KeyValuePair <string, string> > paramList, string url, string apikey = "") { var uri = new Uri(ConnectionHelper.AppUrl + url); var client = new HttpClient(); if (!string.IsNullOrEmpty(apikey)) { //var byteArray = Encoding.UTF8.GetBytes(apikey); //client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(" ", apikey); client.DefaultRequestHeaders.Add("Autenticate", apikey); } if (calltype == ConnectionHelper.WebServiceCallType.Get) { return(client.GetAsync(uri)); } else { var content = new System.Net.Http.FormUrlEncodedContent(paramList); content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/x-www-form-urlencoded"); //var byteArray = Encoding.UTF8.GetBytes(apikey); //content.Headers.Add("Authorization", Convert.ToBase64String(byteArray)); if (calltype == ConnectionHelper.WebServiceCallType.Post) { return(client.PostAsync(uri, content)); } else if (calltype == ConnectionHelper.WebServiceCallType.Put) { return(client.PutAsync(uri, content)); } else { client.BaseAddress = new Uri(""); return(client.DeleteAsync(url)); } } }