Credentials needed for webrequest to Jira?

Vinnie Bartilucci March 22, 2018

Trying to build a service that will grab info on a JIRA ticket based on an ID passed to it.

I'm calling the API to take the ID passed to the service, tack it onto the URL for the API and get the JSON object.

Problem is, it appears one must be logged on or registered on JIRA in order to use the API.

So if I use the code below to make my request, I get a 404 error, as I do on any browser which I've not used to log onto Jira

 

public string Get(string id)
{
string html = string.Empty;
string url = @"https://company.atlassian.net/rest/api/latest/issue/" + id;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
html = reader.ReadToEnd();
}


return html;

}

 

I can add credentials to the request like so

 

 request.Credentials = new NetworkCredential("vinnie@company.com","mypassword");

but I've no idea exactly what needs sending. I've tried the email address with which I'm set up in Jira but that doesn't work.

I have a suspicion that Jira adds a cookie to my browser which it uses to validate after the initial config - is that so?  If so, what can I add/include on my web request to get it to run?

1 answer

1 vote
Alexey Matveev
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.
March 22, 2018

If you use basic authentication, then kindly read this article

https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events