It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira Service Desk API returning 401 from c# web application

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

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 08, 2019 in Jira Service Desk

What's new in Jira Service Desk Server: A stylish new portal in 4.1 - April 2019

Hello Atlassian Community!  I'm Teresa, the Product Marketing Manager   for Jira Service Desk Server at Atlassian. Curious about the latest updates in the Jira Service Desk Server...

328 views 0 3
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