Arya raj

Arya raj

  • NA
  • 57
  • 34.8k

dynamic attributes and values in httpclient getasyn

Jul 13 2019 5:49 AM
I have to get dynamic attributes and values as parameters in httpclient getasync() from angular.no matter what ever attributes and values in params i should be able to get it in httpclient getasync(). i wote a code like below
  1. [HttpGet]  
  2. public async Task<HttpResponseMessage> QuickSearch([FromUri] queryString)  
  3. {  
  4. Debugger.Launch();  
  5. try  
  6. {  
  7. using (HttpClient client = new HttpClient())  
  8. {  
  9. client.DefaultRequestHeaders.Accept.Clear();  
  10. //string queryString = "";  
  11. //if (!string.IsNullOrEmpty(param.ssn))  
  12. //{  
  13. // queryString = "?ssn=" + param.ssn;  
  14. //}  
  15. //if (!string.IsNullOrEmpty(param.applicant))  
  16. //{  
  17. // queryString = "?applicant=" + param.applicant;  
  18. //}  
  19. HttpResponseMessage response = await client.GetAsync("http://localhost:8080/document/quicksearch/" + queryString);  
  20. if (response.IsSuccessStatusCode)  
  21. {  
  22. Console.Write("Success");  
  23. }  
  24. else  
  25. {  
  26. Console.Write("Failure");  
  27. }  
  28. return response;  
  29. }  
  30. }  
  31. catch (Exception e)  
  32. {  
  33. throw e;  
  34. }  
  35. }  

Answers (1)