Hi,
Need some help to understand and how to fix this when trying to connect to jira over c#.
url format is:
String baseURL = "https://mycompanyname.jira.com/rest/";
String loginAPI = "auth/1/session";
Whenever I try to execute this, I get a 401. I've tried using my email with api key, username without email format with api key, and both with password and all get a 401... Totally clueless.
public void loginToJira()
{
try {
WebRequest request = WebRequest.Create(this.baseURL + this.loginAPI);
String postData = "{\"username\":\"" + this.loginUsername + "\",\"password\":\"" + this.loginPassword + "\"}";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/json";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
String responseFromServer = reader.ReadToEnd();
this.loginResponse = responseFromServer;
reader.Close();
dataStream.Close();
response.Close();
}
catch (Exception ex)
{
string texto = ex.Message;
}
}
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.