Authorizing HTTP POST in a C# app

Dennis F Peters
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 23, 2024

Hello, I've been running into issues with getting Jira to accept authorization from requests sent by an app I'm building using .NET. 

When running the same request through cURL I am able to validate without any problems using both the token and username/password. However, inside of the app I cannot validate with either the token or username/password. I have not triggered the CAPTCHA either (yet).


Jira Version: 9.12.1

EXAMPLE CODE

var authenticationString = $"{email}:{token}";
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(authenticationString));
var request = new HttpRequestMessage()
{
RequestUri = new System.Uri($"{baseUri}/rest/api/2/issue/"),
Method = HttpMethod.Post,
Content = new StringContent(unimportant)
};
request.Headers.Authorization = new AuthenticationHeaderValue("basic", base64EncodedAuthenticationString);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.SendAsync(request); 

 

0 answers

Suggest an answer

Log in or Sign up to answer