public static SessionResults GetSessionResults(string apiKey, TestResults testResults) { string apiSessionUrl = testResults?.ApiUrls?.Session; if (string.IsNullOrWhiteSpace(apiSessionUrl)) { return(null); } UriBuilder uriBuilder = new UriBuilder(apiSessionUrl); NameValueCollection query = UrlUtility.ParseQueryString(uriBuilder.Query); query["format"] = "json"; query["AccessToken"] = testResults.SecretToken; query["apiKey"] = apiKey; uriBuilder.Query = query.ToString(); HttpRestClient client = new HttpRestClient(uriBuilder.Uri); SessionResults sessionResults = null; Stopwatch stopwatch = Stopwatch.StartNew(); TimeSpan timeout = TimeSpan.FromSeconds(40); while (sessionResults == null && stopwatch.Elapsed < timeout) { using (HttpResponseMessage metaResults = client.Get(uriBuilder.ToString())) { sessionResults = metaResults.DeserializeBody <SessionResults>(false); } if (sessionResults != null && sessionResults.ActualAppOutput.Length > 0) { break; } System.Threading.Thread.Sleep(500); } return(sessionResults); }
public void GetRequest() { IHttpRestClient http = new HttpRestClient(); var response = http.Get("https://znxt.app/api/ecomm/product/scan/getlinks?filter={$and : [{source:'amazon.in'}, {is_scan : false}]}&pagesize=100"); Assert.IsNotNull(response); }
public void Get_makesNonAuthenicatedApiCallWithNoHeaders_returnsString() { HttpRestClient client = new HttpRestClient(); var result = client.Get <string>("https://api.bitfinex.com/v2/ticker/tETHUSD"); Assert.IsTrue(result.Body.StartsWith("[")); }
public void GetRequest_withQueryString() { IHttpRestClient http = new HttpRestClient(); var response = http.Get("http://23.96.83.176:9090/scan/scan?q=AND"); Assert.IsNotNull(response); }
public void Get_makesNonAuthenicatedApiCallWithNoHeaders_returnsHttpResponse() { HttpRestClient client = new HttpRestClient(); var result = client.Get <ExamplePostResponse>("https://api.coinbase.com/v2/prices/spot?currency=USD"); Assert.AreEqual("USD", result.Body.data.currency); Assert.AreEqual("missing_version", result.Body.warnings[0].id); Assert.AreEqual("Please supply API version (YYYY-MM-DD) as CB-VERSION header", result.Body.warnings[0].message); }
public void FetchAccessToken(string url) { var client = new HttpRestClient(); var response = client.Get <string>(url); if (response.StatusCode == System.Net.HttpStatusCode.OK) { } }
private async void buttonSearch_Click(object sender, EventArgs e) { if (textBoxAreaCode.Text.Length != 3) { labelValidation.Text = "Area Code Must be 3 Digits in Length"; listViewNumbersSearch.Visible = false; } else { buttonSelectNumber.Visible = true; labelValidation.Text = string.Empty; listViewNumbersSearch.Visible = true; _lastSearchedAreaCode = textBoxAreaCode.Text; string url = ApiClient.BuildSearchUrl(textBoxAreaCode.Text); HttpRestClient client = new HttpRestClient(); HttpResponse <string[]> response = client.Get <string[]>(url); if (response.StatusCode == System.Net.HttpStatusCode.OK) { UseWaitCursor = false; if (response.Body != null) { for (int i = 0; i < response.Body.Length; i++) { listViewNumbersSearch.Items.Add(response.Body[i]); } labelValidation.Visible = true; } else { labelValidation.Visible = true; } } else { UseWaitCursor = false; labelValidation.Visible = true; using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(response.ErrorMessage))) { stream.Position = 0; DataContractJsonSerializer serizlizer = new DataContractJsonSerializer(typeof(ErrorResponse)); ErrorResponse errorResponse = serizlizer.ReadObject(stream) as ErrorResponse; labelValidation.Text = errorResponse.Message; } } } }
public void Get_makesNonAuthenicatedApiCallWithHeaderSet_returnsHttpResponse() { HttpRestClient client = new HttpRestClient(); Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("CB-VERSION", "2016-08-10"); var result = client.Get <ExamplePostResponse>("https://api.coinbase.com/v2/prices/ETH-USD/buy", headers); Assert.AreEqual("USD", result.Body.data.currency); Assert.AreEqual("missing_version", result.Body.warnings[0].id); Assert.AreEqual("Please supply API version (YYYY-MM-DD) as CB-VERSION header", result.Body.warnings[0].message); }
public void GetRequest_fail() { try { IHttpRestClient http = new HttpRestClient(); var response = http.Get("https://znxt.app/api/abc/abc"); Assert.Fail(); } catch (ApplicationException ex) { Assert.IsNotNull(ex.InnerException); } }
public IHttpActionResult GetPatientInfo() { try { if (string.IsNullOrEmpty(Cache.AuthToken.Instance().GetAccessToken())) { if (string.IsNullOrEmpty(Cache.AuthToken.Instance().GetCode())) { return(BadRequest("Authoriaztion Code is empty")); } var authResponse = GetAuthResponse(); if (authResponse.StatusCode != HttpStatusCode.OK) { return(BadRequest(authResponse.ErrorMessage)); } } Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Authorization", "Bearer " + Cache.AuthToken.Instance().GetAccessToken()); HttpRestClient client = new HttpRestClient(); var patientResponse = client.Get <EpicPatientResposne>( "https://open-ic.epic.com/argonaut/api/FHIR/Argonaut/Patient/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", headers); var immunizationResponse = client.Get <EpicVacinationsResponse>( "https://open-ic.epic.com/FHIR/api/FHIR/DSTU2/Immunization?patient=Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB", headers); return(Ok(new PatientResposne(patientResponse.Body, immunizationResponse.Body))); } catch (Exception ex) { return(InternalServerError(ex)); } }
public AuthMetaDataResponse MakeMetaDataRequest() { const string baseUrl = "https://open-ic.epic.com/Argonaut/api/FHIR/Argonaut/metadata"; var client = new HttpRestClient(); var response = client.Get <AuthMetaDataResponse>(baseUrl); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(response.Body); } else { return(null); } }
public override async void SetupNode(int nodeNumber) { var response = await HttpRestClient.Get(Helpers.RegisterSubscriberUrl(ConfigurationFile.BaseUrl)); Nodes[nodeNumber] = JsonConvert.DeserializeObject <SubscriberMetadata>(response); Console.WriteLine($"Subscriber {nodeNumber} created. Queue Name: {Nodes[nodeNumber].QueueUrl}"); if (ConfigurationFile.ProviderType == ProviderType.Azure) { Subscribers[nodeNumber] = new AzureSubscriber(Nodes[nodeNumber]); } else { Subscribers[nodeNumber] = new AwsSubscriber(Nodes[nodeNumber]); } Subscribers[nodeNumber].Setup(); CallFunctions(nodeNumber); }
public static BatchInfo GetBatchInfo(EyesBaseConfig eyes) { UriBuilder uriBuilder = new UriBuilder(eyes.ServerUrl); uriBuilder.Path = $"api/sessions/batches/{eyes.Batch.Id}/bypointerid"; NameValueCollection query = HttpUtility.ParseQueryString(uriBuilder.Query); query["apiKey"] = eyes.ApiKey; uriBuilder.Query = query.ToString(); HttpRestClient client = new HttpRestClient(uriBuilder.Uri); using (HttpWebResponse batchInfoResponse = client.Get(uriBuilder.ToString())) { BatchInfo batchInfo = batchInfoResponse.DeserializeBody <BatchInfo>(false); return(batchInfo); } }
public string FetchImmunizationData(string accessToken) { const string patientUrl = "https://open-ic.epic.com/argonaut/api/FHIR/Argonaut/Immunization/Tbt3KuCY0B5PSrJvCu2j-PlK.aiHsu2xUjUM8bWpetXoB"; Dictionary <string, string> headers = new Dictionary <string, string>(); headers.Add("Authorization", "Bearer " + accessToken); var client = new HttpRestClient(); var response = client.Get <string>(patientUrl, headers); if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(response.Body); } else { return(null); } }
private static SessionResults GetSessionResults_(Eyes eyes, TestResults results) { string apiSessionUrl = results.ApiUrls?.Session; SessionResults sessionResults = null; if (apiSessionUrl != null) { var uriBuilder = new UriBuilder(apiSessionUrl); var query = HttpUtility.ParseQueryString(uriBuilder.Query); query["format"] = "json"; query["AccessToken"] = results.SecretToken; query["apiKey"] = eyes.ApiKey; uriBuilder.Query = query.ToString(); HttpRestClient client = new HttpRestClient(uriBuilder.Uri); var metaResults = client.Get(uriBuilder.ToString()); sessionResults = metaResults.DeserializeBody <SessionResults>(false); } return(sessionResults); }
public static SessionResults GetSessionResults(string apiKey, TestResults testResults) { string apiSessionUrl = testResults?.ApiUrls?.Session; if (string.IsNullOrWhiteSpace(apiSessionUrl)) { return(null); } UriBuilder uriBuilder = new UriBuilder(apiSessionUrl); NameValueCollection query = HttpUtility.ParseQueryString(uriBuilder.Query); query["format"] = "json"; query["AccessToken"] = testResults.SecretToken; query["apiKey"] = apiKey; uriBuilder.Query = query.ToString(); HttpRestClient client = new HttpRestClient(uriBuilder.Uri); HttpWebResponse metaResults = client.Get(uriBuilder.ToString()); SessionResults sessionResults = metaResults.DeserializeBody <SessionResults>(false); return(sessionResults); }
public static string GetDom(string apiKey, TestResults testResults, string domId) { string apiSessionUrl = testResults?.AppUrls?.Session; if (string.IsNullOrWhiteSpace(apiSessionUrl)) { return(null); } UriBuilder uriBuilder = new UriBuilder(apiSessionUrl); NameValueCollection query = UrlUtility.ParseQueryString(uriBuilder.Query); query["apiKey"] = apiKey; uriBuilder.Query = query.ToString(); uriBuilder.Path = $"/api/images/dom/{domId}/"; HttpRestClient client = new HttpRestClient(uriBuilder.Uri); using (HttpResponseMessage response = client.Get(uriBuilder.ToString())) using (Stream s = response.GetResponseStream()) { var json = new StreamReader(s).ReadToEnd(); return(json); } }
public override async Task <string> ExecuteFunction(object parameters) { return(await HttpRestClient.Get(FunctionAddress)); }