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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

176 views 2 0
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