How to authenticate to OnDemand from .Net

Sean June 11, 2013

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

0 votes
Answer accepted
Sean October 18, 2013

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.)

0 votes
Deleted user October 17, 2013

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.

0 votes
Sean June 12, 2013

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.)

Suggest an answer

Log in or Sign up to answer