string data = @"{""fields"":{""project"":{""key"": ""md""},""summary"": ""reset example"",""description"": ""creating an issue via rest api"",""issuetype"": {""name"": ""bug""}}}";
//string postUrl = "https://aconline.atlassian.net/rest/api/2/issue/";
string postUrl = "https://aconline.atlassian.net/rest/api/2/issue";
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
client.BaseAddress = new System.Uri(postUrl);
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.Formatting.MediaTypeFormatter jsonFormatter = new System.Net.Http.Formatting.JsonMediaTypeFormatter();
//< Issue & gt;
System.Net.Http.HttpContent content = new System.Net.Http.ObjectContent<string>(data, jsonFormatter);
//var content = new StringContent(data, Encoding.UTF8, "application/json");
System.Net.Http.HttpResponseMessage response = client.PostAsync("issue", content).Result;
if (response.IsSuccessStatusCode)
{
//descrptiontextBox.Text = result;
ViewData["Result"] = response.Content.ReadAsStringAsync().Result;
}
else
{
//descrptiontextBox.Text = response.StatusCode.ToString();
ViewData["Result"] = response.StatusCode.ToString();
}
Have a look at the response message, which Jira returns. There will a detailed explanation of your error. Or install Rest Browser plugin and execute your rest method there. You will see the error.
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.