这是我在c#中的代码,它给出了错误的请求错误
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();
}