Jira Service Desk API returning 401 from c# web application

NJA I'm New Here Jan 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 vote
NJA I'm New Here Jan 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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jun 14, 2018 in Jira Service Desk

How the Telegram Integration for Jira helps Sergey's team take their support efficiency to the bank

...+ reading Fantasy). The same is true for him at the bank he works for: Efficiency is key when time literally equals money. Read on to learn how Sergey makes most of the time he has by...

784 views 5 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you