// initialize a HttpClient with the Jira base url, e.g. "https://my.atlassian.net/jira"
using HttpClient client = new() { BaseAddress = new Uri(Config.JiraBaseUrl) };
// authentication can be done by either using a Jira PAT + Bearer or Jira username with password + Basic authentication header
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Config.JiraPAT);
client.DefaultRequestHeaders.Authorization =new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(String.Format("{0}:{1}", Config.JiraUserName, Config.JiraPassword)))); |