Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unauthorized Error while accessing Jira cloud rest api for Login in C#

Kirankumar Ek May 21, 2019

I was trying to access JIRA login apis from the C# code and Unauthorized error is displayed. 

The code snippet is given below:

var mergedCredentials = string.Format("{0}:{1}", "<username>", "<password>");
var byteCredentials = Encoding.UTF8.GetBytes(mergedCredentials);
var encodedCredentials = Convert.ToBase64String(byteCredentials);

using (WebClient webClient = new WebClient())
{
webClient.Headers.Set("Authorization", "Basic " + encodedCredentials);

return webClient.DownloadString("https://<jira_url>/rest/auth/1/session");
}

Can you please help me to resolve the issue? The username and password are the ones which we use to login to our jira url. Even substituted the Profile name as the user name and the Jira token as the password. Still getting the Unauthorized error.

1 answer

0 votes
Kirankumar Ek May 22, 2019

Hi,

Is there any solution for this? Any help is appreciated.

Suggest an answer

Log in or Sign up to answer