1. Get products ASYNC in c#
HttpClientHandler handler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }; using (var client = new HttpClient(handler)) { client.BaseAddress = new Uri("https://api.hlc.bike/"); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("ApiKey", "KEY"); //JSON VS XML --- client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("v3.0/Catalog/Products").Result; if (response.IsSuccessStatusCode) { //OK } else { //NOK } }
2. Get brands in JAVA
CloseableHttpClient httpClient = null; HttpResponse response = null; BufferedReader reader = null; try { httpClient = HttpClientBuilder.create().build(); HttpGet request = new HttpGet("https://api.hlc.bike/us/v3.0/Catalog/Brands"); request.setHeader(HttpHeaders.ACCEPT, "application/json"); request.setHeader(HttpHeaders.ACCEPT_ENCODING, "gzip"); request.setHeader(HttpHeaders.AUTHORIZATION, "ApiKey YOUR KEY"); request.addHeader("language", "en"); response = httpClient.execute(request); if (response.getStatusLine().getStatusCode() == 200) { reader = new BufferedReader( new InputStreamReader((response.getEntity().getContent())) ); String output; while ((output = reader.readLine()) != null) { System.out.println(output); retVal = retVal.append(output); } } else { return false; } } .....