프로젝트 생성을 위해 json 데이터로 JIRA에 POST 요청을 보내고 있지만 JIRA로 프로젝트를 생성 할 수 없습니다. Fiddler에서 오류를 보려고했는데 다음 오류가 발생했습니다. 나는 C#을 사용하고 그것을위한 콘솔 어플리케이션을 만들었다.JIRA에 문제를 생성하는 방법 REST api?
내가 게시하는 내 JSON 데이터는 다음과 같습니다.
{
"fields": {
"project": {
"key": "JTL"
},
"issuetype": {
"name": "BUG"
}
}
}
오류 메시지는 다음입니다 :
{ "errorMessages"[] "오류": { "issuetype": "문제 유형이 필요합니다"}}
I 다음 코드에서 json 데이터를 게시하고 있습니다. 무엇을 그리고 어디서 내가 틀렸는 지 제안하십시오.
string [email protected]"{"fields":{"project":{"key":"JTL"},"issuetype":{"name":"BUG"}}}";
//object of HttpClient.
HttpClient client = new HttpClient();
//Putting URI in client base address.
client.BaseAddress = new Uri(uri);
//Putting the credentials as bytes.
byte[] cred = UTF8Encoding.UTF8.GetBytes("jiraUserName" + ":" + "JiraPassword");
//Putting credentials in Authorization headers.
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
//Putting content-type into the Header.
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
//i am using StringContent because i am creating console application, no any serialize i used for maniputlate the string.
var content = new StringContent(data, Encoding.UTF8, "application/json");
//Sending the Post Request to the server. But getting 400 bad Request.
System.Net.Http.HttpResponseMessage response = client.PostAsync("issue", content).Result;
위의 코드에서 사용자 인증 및 데이터 전송을위한 자격 증명을 보냈습니다.
JSON 출력 데이터에'issuebug' 키가 포함되어 있는지 100 % 확신합니까? –
그래, 내 긍정에 대한 이유가있다, 내 현재 json 설명 및 여름 키가 결석하지만 응답보다 "여름"과 "설명"두 키와 함께 json 데이터를 보낼 때 unknon 또는 없습니다 필수,보다 두 키 값을 모두 제거했지만 JIRA REST API 문서에서는 두 키가 예제에서 사용되었습니다. –
올바른 엔드 포인트에 액세스하고 있습니까? 적절한 URL을 의미합니까? –