I havent found a solution to this problem yet, and the only other similar question on here was resolved but the links of the solution are obsolete.
When i try to use the generate JiraClient from this output if i use my password it works, if i use my Personal Access Token (PAT) which i generated on my account from JIRA i get a 401 Error.
return Jira.CreateRestClient(jUrl, userName, userPersonalJiraToken);
Hi,
a bit late to the party, but i solved the problem this way:
Create a class authenticator
public class PATTokenAuthentication : RestSharp.Authenticators.IAuthenticator
{
private string _token;
public PATTokenAuthentication(string token)
{
_token = token;
}
public void Authenticate(IRestClient client, IRestRequest request)
{
request.AddHeader("Authorization", $"Bearer {_token}");
}
}
And then use it in the RestSharp settings:
var jira = Jira.CreateRestClient("<URL>", null, null);
jira.RestClient.RestSharpClient.Authenticator = new PATTokenAuthentication("<Your PAT>");
var issuesQuery = from i in jira.Issues.Queryable
orderby i.Created
select i;
var issuesList = issuesQuery.ToList();
issuesList should be populated correctly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.