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

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

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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

21,689 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you