I am having trouble using the Jenkins API to reach an endpoint. My Jenkins is hosted on IIS setup using the following: https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+behind+IIS
My IIS site has Windows authentication only - this cannot be changed because it's how the organisation has established it. Therefore, when making the call I need to pass my username and password as my credentials leaving out the API token. When I try a similar request in Curl it says I am authenticated as Anonymous (I cannot change any Jenkins security configurations). Suggesting that the API token is required.
Is there a way I can provide my username, password and API token to overcome this 403 issue in a C# console app OR using Curl?
C# Code
HttpWebRequest initRequest = (HttpWebRequest)HttpWebRequest.Create("https://jenkinsdomain.co.uk/api/json?pretty=true");
initRequest.Method = "GET";
initRequest.UseDefaultCredentials = false;
initRequest.Credentials = new NetworkCredential("username", "password");
try
{
HttpWebResponse response = (HttpWebResponse)initRequest.GetResponse(); // Raises Unauthorized Exception
Console.Write(response.StatusCode);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Thanks!