private string ExecuteRequest(Dictionary <string, string> request, Regions region) { SignedRequestHelper helper = new SignedRequestHelper(this.AWS_ACCESS_KEY, this.AWS_SECRET_KEY, RegionUrlMapping[region]); string requestUri = helper.Sign(request); string response = RestApiUtils.ExecuteRestApi(requestUri); return(response); }
private string GetTextFromUrl(string url) { string baseUrlFormat = @"https://access.alchemyapi.com/calls/url/URLGetText?url={0}&apikey={1}"; string requestUri = string.Format(baseUrlFormat, url, this.AlchemyApiKey); string response = RestApiUtils.ExecuteRestApi(requestUri); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(response); string text = xmlDoc.GetElementsByTagName("text")[0].InnerText; return(text); }
public void ApiRequestTest() { RestApiUtils restApiUtils = new RestApiUtils(); IRestResponse response = restApiUtils.postRequest(EndPints.Peoples); JObject jo = JObject.Parse(response.Content); JArray jArray = (JArray)jo["contextWrites"]["to"][0]["results"]; List <People> peoples = JsonConvert.DeserializeObject <List <People> >(jArray.ToString()); foreach (People p in peoples) { Console.WriteLine(p.Name + " " + p.SkinColor); } }
public void CheckServiceHeartbeat() { while (true) { string requestUri = string.Format("{0}?heartbeat=true", this.serviceApiEndpoint); var response = RestApiUtils.GetHttpResponse(requestUri); if (response == null || response.StatusCode != HttpStatusCode.OK) { //Send service heartbeat not working mail } Thread.Sleep(waitTimespan); } }