How to authenticate to OnDemand from .Net

I can successfully connect to Jira using the Chrome Rest Console and get an issue in JSON. I used basic authentication. However, I cannot seem to do this from my local development PC using a .net web application. I've tried connecting using System.Net.WebRequest, System.Net.Http.HttpClient, jQuery.getJSON and even tried the Atlassian.Net SDK from NuGet.

All of these are giving me a 401 Unauthorized message. I'm confident my username and password are correct and base64ed fine since it works in the Rest Console.

I've tried code similar to this "answer" but am still 401 errors: https://answers.atlassian.com/questions/79902/using-httpclient-c-to-create-a-jira-issue-via-rest-generates-bad-request-response

Does anyone have suggestions on what I can do to determine the issue? Is it related to running locally? Is there a specific part of the header that would cause this particular error message (althougth I've tried mirroring what the Chrome Console is sending)?

3 answers

1 accepted

Accepted Answer
0 votes

Yes.

I was logged into Jira in a browser, then running the Chrome Rest Console. The session was alive from the Jira login so it was burrying the fact that the Rest Console was not actually logging in.

I finallly found that the problem was using my email address and not my user login. I used my email becase that is what Jira was showing me in the browser. I didn't figure this out faster because of the console issue. So, make sure that you are using your Jira login and password (and not your email or any OAuth info.)

UPDATE: I just realized that it was working in the Chrome Rest Console only when I had another tab logged into Jira. When I logged out of Jira in the separate tab, the console gave me the 401 Unauthorized message. So, apparently the Console was not working afterall and instead using my browser session?

I've also tried using https://myDomain.atlassian.net/rest/api/2/issue/DEMO-2?os_username=myLogin&os_password=myPassword. This did not work either.

I still cannot figure out how to authenticate. I'm wondering if it has something to do with the Google integration, although I'm using my Jira login and password (not my Google one.)

Hi Sean, did you ever figure this out? We are running into the same problem when trying to authenticate to OnDemand using Basic authentication from .NET.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

456 views 7 5
Join discussion

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