public static dynamic GetResponse(ExtApiType prjDcsType, List<string> param) { //Do you have the security mode set to Transport in your config? using (var client = new HttpClient()) { dynamic result = null; if (prjDcsType == ExtApiType.LauchSite_GetFoldersRollforward) client.BaseAddress = new Uri(ConfigUtility.GetLauchSite_baseUri); else client.BaseAddress = new Uri(ConfigUtility.GetPrjNDcs_baseUri); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var strUrl = string.Format("{0}{1}", GetUrl(prjDcsType), string.Join("/", param)); HttpResponseMessage response = client.GetAsync(strUrl).Result; if (response.IsSuccessStatusCode) { result = response.Content.ReadAsAsync<dynamic>().Result; } if (prjDcsType == ExtApiType.Dcs && result == null) result = GetResponse(ExtApiType.DcsAll, new List<string> { }); return result; } }
private static string GetUrl(ExtApiType extApiType) { switch (extApiType) { case ExtApiType.Prj: return(ConfigUtility.GetPrjNDcs_url_Prj); case ExtApiType.Dcs: return(ConfigUtility.GetPrjNDcs_url_Dcs); case ExtApiType.DcsAll: return(ConfigUtility.GetPrjNDcs_url_Dcs_All); case ExtApiType.LauchSite_GetFoldersRollforward: return(ConfigUtility.GetLauchSite_url_GetFoldersRollforward); } return(null); }
public static dynamic GetResponse(ExtApiType prjDcsType, List <string> param) { //Do you have the security mode set to Transport in your config? using (var client = new HttpClient()) { dynamic result = null; if (prjDcsType == ExtApiType.LauchSite_GetFoldersRollforward) { client.BaseAddress = new Uri(ConfigUtility.GetLauchSite_baseUri); } else { client.BaseAddress = new Uri(ConfigUtility.GetPrjNDcs_baseUri); } client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var strUrl = string.Format("{0}{1}", GetUrl(prjDcsType), string.Join("/", param)); HttpResponseMessage response = client.GetAsync(strUrl).Result; if (response.IsSuccessStatusCode) { result = response.Content.ReadAsAsync <dynamic>().Result; } if (prjDcsType == ExtApiType.Dcs && result == null) { result = GetResponse(ExtApiType.DcsAll, new List <string> { }); } return(result); } }
private static string GetUrl(ExtApiType extApiType) { switch (extApiType) { case ExtApiType.Prj: return ConfigUtility.GetPrjNDcs_url_Prj; case ExtApiType.Dcs: return ConfigUtility.GetPrjNDcs_url_Dcs; case ExtApiType.DcsAll: return ConfigUtility.GetPrjNDcs_url_Dcs_All; case ExtApiType.LauchSite_GetFoldersRollforward: return ConfigUtility.GetLauchSite_url_GetFoldersRollforward; } return null; }