Jira Service Desk API returning 401 from c# web application

NJA January 19, 2018

This code was working and now it returns a 401 error (System.Net.HttpStatusCode.Unauthorized).

However, if I log into Jira and then open a new tab I can paste in the api call and poof, instant json response. So it appears that the credentials are correct.

I see that other people have this problem and then it starts working again, but that is not the case here. This is really a downer, because since it was working I have a really nice tableau report based on the results that I was saving to a database.

Any help would be appreciated.

-------

        var uriString = "https://journal.atlassian.net/rest/servicedeskapi/request?start=" + start.ToString() + "&limit=" + limit.ToString();
        var uri = new Uri(uriString);

        //var username = "my.email@someplace.com";
        //var password = "mypassword";

        var username = util.GetJiraAPIusername();
        var password = util.GetJiraAPIpassword();

        ViewBag.URI = uri;
        var client = new HttpClient();        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}")));        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        HttpResponseMessage response = client.GetAsync(uri).Result;  // Blocking call!
        if (response.IsSuccessStatusCode){ 

 

1 answer

0 votes
NJA January 29, 2018

This doesn't necessarily solve the problem for me due to my vendor support, but Atlassian support provided this information. 

-------------------------------

User is a Service Desk portal user. There were changes not so long time ago where Service Desk portal user is not allowed not authenticate via REST API any more.

We are offering API tokens as an alternative for authentication. In order to make it work, your user should be converted to Atlassian Account first. These changes can be done by a site administrator of the Jira instance. Thus, you will need to contact them to clarify this question first.

The following article explains changes and instructions about what should be done, you can pass it to site administrator:
https://confluence.atlassian.com/cloudkb/jira-service-desk-cloud-rest-api-changes-to-atlassian-account-940700797.html

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events