JIRA Rest API Login using C#

Vasantha Bhat August 7, 2012
I've written below C# code to login to JIRA Rest API:

var url = new Uri("http://localhost:8090/rest/auth/latest/session?os_username=tempusername&os_password=temppwd");
var request = WebRequest.Create(url) as HttpWebRequest;
if (null == request)
{
return "";
}
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = 200;
request.KeepAlive = false;
using (var response = request.GetResponse() as HttpWebResponse)
{
}


When I execute this, application just goes on running without returning any response. Please suggest if this is the right way of calling JIRA Loin using REST API

2 answers

1 vote
Harry Chan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2012

Hi, as you are sending data via POST, you cannot simply add os_username and os_password to your URI string. Refer to the WebRequest documentation on how this can be done in C#.

Please refer to this link for an example on basic REST API authentication.

If you need OAuth, refer to this link.

0 votes
Will Burton August 21, 2012

It's there a reason you only want to login? I generally just use HTTP Basic Auth with my REST request.

Suggest an answer

Log in or Sign up to answer