public async Task <List <CensysSearchResult> > SearchData(string index, CensysSearchPost body) { var searchResult = await _api.Search(index, body); Console.WriteLine(searchResult.Response[0].Status); return(searchResult.Response); }
public async Task <CensysJsonResult> GetJsonSearchData(IndexEnum index, CensysSearchPost body) { using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = _authorizationHeader; var json = JsonConvert.SerializeObject(body); var data = new StringContent(json, Encoding.UTF8, "application/json"); var url = $"{_baseUrl}/search/{index}"; var response = await client.PostAsync(url, data); var message = $"Request Message Information:- \n\n{response?.RequestMessage}\n\n\n"; message += $"Response Message Header \n\n {response?.Content?.Headers}\n"; if (((int)response.StatusCode >= 200) && ((int)response.StatusCode <= 299)) { var jsonResult = await response.Content.ReadAsStringAsync(); return(new CensysJsonResult { IpRange = body.query, Json = jsonResult, ResponseMessage = message, ResponseStatusCode = response.StatusCode.ToString() }); } return(new CensysJsonResult { IpRange = body.query, ResponseMessage = message, ResponseStatusCode = response.StatusCode.ToString() }); } }