Hi All,
I am trying to create an issue using the REST service trough C# (.NET). However i can't seem to send a correct json request i use the code below. I read that many developers have this problem could sombody help ?
Thanks in advance.
Vars i use to feed the REST Service
var JiraBaseURL = "https://xxx.atlassian.net/rest/api/2/issue"; var post_json = "\"fields\": { \"project\": { \"id\": \"TJI\" }, \"description\": \"Hellow why doesn't this work\", \"summary\": \"REST ye merry gentlemen.\", \"issuetype\": { \"name\": \"Bug\" } } ";
// The code to call the service
string mergedCredentials = string.Format("{0}:{1}", User, Pass);
byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials); var Credentials = Convert.ToBase64String(byteCredentials); HttpWebRequest request = WebRequest.Create(JiraBaseURL) as HttpWebRequest; request.ContentType = "application/json"; request.Method = "POST"; if (post_json != null) { using (StreamWriter writer = new StreamWriter(request.GetRequestStream())) { writer.Write(post_json); } } request.Headers.Add("Authorization", "Basic " + Credentials); HttpWebResponse response = request.GetResponse() as HttpWebResponse; string result = string.Empty; using (StreamReader reader = new StreamReader(response.GetResponseStream())) { result = reader.ReadToEnd(); }
Community moderators have prevented the ability to post new answers.
Are you able to get response here (in this line) ? HttpWebResponse response = request.GetResponse() as HttpWebResponse; I'm having problem, its saying unable to connect server? Are you getting this problem? or Its OK and you are getting proper response?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.