I have been searching and working on how to get Jira REST response for quite some time now. The problem is when it gets to this code, an exception will be raised, either BAD REQUEST or INTERNAL SERVER ERROR.
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
It never go beyond this code. Instead, I am expecting:
}
"errorMessages": [],
"errors": {
"message": "An error occured ... "
}
}
for error messages or:
}
"id": "11600",
"key": "RP-547",
"self": "http://jira.com/rest/api/2/issue/11600"
}
on success.
Is there some thing I missed, or misunderstood? How do I get the expected results?
Some extra info:
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.ContentType = "application/json";
request.Accept = "application/json";
request.Method = method; //POST
if (data != null)
{
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(data);
}
}
string base64Credentials = GetEncodedCredentials();
request.Headers.Add("Authorization", "Basic " + base64Credentials);
string result = string.Empty;
HttpWebResponse response = request.GetResponse() as HttpWebResponse; //breaks here
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
result = reader.ReadToEnd();
}