Advertisement
inoonan

C# get request

Oct 16th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1.         public static async Task<string> GetState(int functionalAreaId)
  2.         {
  3.             try
  4.             {
  5.                 UriBuilder uriBuilder = new UriBuilder
  6.                 {
  7.                     Scheme = Program.AppSettings.FrmOptions.StateMachine.Schema,
  8.                     Host = Program.AppSettings.FrmOptions.StateMachine.Host,
  9.                     Port = Convert.ToInt32(Program.AppSettings.FrmOptions.StateMachine.Port),
  10.                     Path = "StateMachine/GetState",
  11.                     Query = $"functionalAreaId={functionalAreaId}",
  12.                 };
  13.  
  14.                 using (HttpClient client = new HttpClient())
  15.                 {
  16.                     HttpResponseMessage response = await client.GetAsync(uriBuilder.Uri);
  17.                     string json = await response.Content.ReadAsStringAsync();
  18.                     return json;
  19.                 }
  20.             }
  21.             catch (Exception ex)
  22.             {
  23.                 return ex.Message;
  24.             }
  25.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement