You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
905 B

4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Net.Http;
  6. using System.Net.Http.Headers;
  7. using System.Text;
  8. namespace Common
  9. {
  10. public class RestApiClient
  11. {
  12. private static int timeOut = 100;//Convert.ToInt16(ConfigurationManager.AppSettings["ApiTimeOutSeconds"]);
  13. public static HttpClient CallJMEThirdParty()
  14. {
  15. string thirdPartyUrl = ConfigurationManager.AppSettings["JMECoreAPIURL"].ToString();
  16. var httpClient = new HttpClient();
  17. httpClient.BaseAddress = new Uri(thirdPartyUrl);
  18. httpClient.DefaultRequestHeaders.Add("apiAccessKey", ConfigurationManager.AppSettings["JMECoreAPI_HeaderToken"].ToString());
  19. httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  20. httpClient.Timeout = new TimeSpan(0, 0, timeOut);
  21. return httpClient;
  22. }
  23. }
  24. }