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

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 14 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

41 views 1 0
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