hi friends,
If there is any possibility to add the new component into the JIRA project by using the c#.net?
Thanks in advance,
Karthik.
Community moderators have prevented the ability to post new answers.
HI Karthik,
Please refer the below coding for adding component for particualr issue in JIRA
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Text; namespace ConsoleApplication2 { class Program { private const string URL = "https://XXXX/rest/api/2/component"; private const string DATA = @"{ ""name"": ""Component 2"", ""description"": ""This is a JIRA component"", ""leadUserName"": ""xx"", ""assigneeType"": ""PROJECT_LEAD"", ""isAssigneeTypeValid"": false, ""project"": ""TP""}"; static void Main(string[] args) { AddComponent(); } private static void AddComponent() { System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); client.BaseAddress = new System.Uri(URL); byte[] cred = UTF8Encoding.UTF8.GetBytes("username:password"); client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred)); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); System.Net.Http.HttpContent content = new StringContent(DATA, UTF8Encoding.UTF8, "application/json"); HttpResponseMessage messge = client.PostAsync(URL, content).Result; string description = string.Empty; if (messge.IsSuccessStatusCode) { string result = messge.Content.ReadAsStringAsync().Result; description = result; } } } }
i think this is what you are looking for
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System; using System.Web; using System.Net; using System.IO; namespace ConsoleProgram { public class Class1 { private const string URL = "https://localhost:8080/rest/api/2/component"; private const string DATA = @"{"name": "Component 1","description": "This is a JIRA component","leadUserName": "fred","assigneeType": "PROJECT_LEAD", "isAssigneeTypeValid": false,"project": "PXA"}"; static void Main(string[] args) { Class1.CreateObject(); } private static void CreateObject() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = DATA.Length; using (Stream webStream = request.GetRequestStream()) using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII)) { requestWriter.Write(DATA); } try { WebResponse webResponse = request.GetResponse(); using (Stream webStream = webResponse.GetResponseStream()) { if (webStream != null) { using (StreamReader responseReader = new StreamReader(webStream)) { string response = responseReader.ReadToEnd(); Console.Out.WriteLine(response); } } } } catch (Exception e) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(e.Message); } } } }
check this
http://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c
and also check
https://answers.atlassian.com/questions/162294/add-new-component
i suggest to google it for REST client in C# you will get tons of samples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to use REST (/rest/api/2/component) api to create component,
check this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.