HMRC Hello World


namespace consoleapp1 
{
  class Program
  {
    private static readonly
    System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();

    //--------------------------------------------------------------------------------------
    static async
    System.Threading.Tasks.Task
    Main(string[] args)
    {
      var response = await Method_HelloWorld();

      Console.WriteLine(response);
    }
    //--------------------------------------------------------------------------------------
    private static async
    System.Threading.Tasks.Task<string>
    Method_HelloWorld()
    {
      client.DefaultRequestHeaders.Accept.Clear();

      client.DefaultRequestHeaders.Accept.Add(
          new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/vnd.hmrc.1.0+json"));

      System.Net.Http.HttpResponseMessage response =
      await client.GetAsync("https://test-api.service.hmrc.gov.uk/hello/world");

      string response_string =
      await response.Content.ReadAsStringAsync();

      if (response is not null)
      {
        return response_string;
      }
      else
      {
        return "";
      }
    }
    //--------------------------------------------------------------------------------------
  }
}


© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext