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 vote

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,296 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot