How to retrieve Jira issues using C# and the Jira API?

public ActionResult fetchJiraIssues(string user, string pass, string apiUrl)
{   
   string apiEndpoint = apiUrl + "/rest/api/2/query";

   var httpClient = new HttpClient { BaseAddress = new Uri(apiEndpoint) };

   var authInfo = Encoding.ASCII.GetBytes(user + ":" + pass);

   httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(authInfo));

   httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

   HttpResponseMessage response = httpClient.GetAsync(apiEndpoint).Result;

   if (response.IsSuccessStatusCode)
   {
      // Process response
   }
}

I’m receiving a StatusCode of 401 with the message ‘Unauthorized’. The API URL is accurate since I successfully retrieve JSON data directly in the browser. Additionally, my username and password are confirmed to be correct. Can anyone help identify what might be wrong in my implementation? Thank you.