string JsonString = @"{
""fields"": {
""project"":
{
""key"": ""ABC""
},
""summary"": ""Summary"",
""description"":
{
""type"":""doc"",
""version"":1,
""content"":[
{
""type"":""paragraph"",
""content"":[
{
""type"":""text"",
""text"":""Description""
}
]
}
]
},
""customfield_10011"": ""XYZ"",
""issuetype"":
{
""name"": ""Epic""
}
}
string restUrl = String.Format("{0}rest/api/2/issue/", Url);
HttpWebResponse response = null;
HttpWebRequest request = WebRequest.Create(restUrl) as HttpWebRequest;
request.Method = "POST";
request.Accept = "application/json";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Basic " + EpicModel.GetEncodedCredentials(UserName, Password));
byte[] data = Encoding.UTF8.GetBytes(JsonString);
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(data, 0, data.Length);
requestStream.Close();
}
using (response = request.GetResponse() as HttpWebResponse)
{
if (response.StatusCode == HttpStatusCode.Created)
{
var reader = new StreamReader(response.GetResponseStream());
string str = reader.ReadToEnd();
//var jss = new System.Web.Script.Serialization.JavaScriptSerializer();
//var sData = jss.Deserialize<Dictionary<string, string>>(str);
//string issueKey = sData["key"].ToString();
}
}
request.Abort();
I think that you miss the field "Epic Name" that maybe is mandatory to fill with a value
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.