Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

404 server not found exception when working with jira instance of type http://machinename:port

Automation Group
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 13, 2016
Hi
The below code is working fine for JIRA machine having of type https://machinename
but the same code is throwing 404 server not found exception in response when I use a different JIRA machine of url  http://machinename and when I checked for the same in Mozilla rest client for post request it throws 403 forbidden error.
What changes do I need to do for the url's starting from http:// . Kindly let me know
Below is the code
string Url ="https://jiraasp.atlassian.net/rest/api/latest/issue/";
string base64Credentials = GetEncodedCredentials();         
HttpWebResponse response = null;
 HttpWebRequest request = WebRequest.Create(Url) as HttpWebRequest;
 
       request.ContentType ="application/json";
 
       request.MediaType ="application/json";
 
       request.Accept ="application/json";
 
       request.Method ="POST"; 
  request.Headers.Add("Authorization", "Basic " + base64Credentials);
 
byte[] data = Encoding.UTF8.GetBytes(objJIRAData.JsonString);
using (var requestStream = request.GetRequestStream())            {
                requestStream.Write(data, 0, data.Length);
                requestStream.Close();
            }
using (response = request.GetResponse() as HttpWebResponse)
            {
if (response.StatusCode != HttpStatusCode.OK)
                {
var reader = new StreamReader(response.GetResponseStream());
                    status = response.StatusCode.ToString();
string str = reader.ReadToEnd();
Console.WriteLine("The server returned '{0}'\n{1}", response.StatusCode, str);
var jss = new System.Web.Script.Serialization.JavaScriptSerializer();
var sData = jss.Deserialize<Dictionary<string, string>>(str);
                    JiraKeyValue = sData["key"].ToString();
                }
            }

 

1 answer

0 votes
Nic Brough -Adaptavist-
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.
January 13, 2016

First, check if the machine is even listening on http.  What do you get when you visit it with a browser?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events