I generally use a URL like the following in order to see an item in the Jira backlog:
https://{server name}/jira/secure/RapidBoard.jspa?rapidView=6588&view=planning&selectedIssue=C165889-1670
And I use a URL like the following in order to view a specific story:
https://{server name}/jira/browse/C165889-1670
Now I want to create a subtask via C#, so I tried the following code:
public static async Task<string> CreateSubTask()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
using (var reader = new StreamReader(await (await client.PostAsJsonAsync(
"https://{server name}/jira/secure/rest/api/latest/issue/",
new
{
project = new {key = "My Project"},
parent = new {key = "C165889-1670"},
summary = "My Summary",
description = "My Description",
issuetype = new {id = 5}
})).Content.ReadAsStreamAsync()))
return await reader.ReadToEndAsync();
}
But when I check the returned string, I find a message like the one in https://jira.atlassian.com/secure/attachment/180809/screenshot-2.png - a dead link page.
Can anyone tell me what I am doing wrong?
Thanks in advance,
Itai
Hey Itai,
A REST endpoint doesn't include /secure.
Instead of https://{server name}/jira/secure/rest/api/latest/issue, can you try this:
Cheers,
Andy
Hey, Andy. Thanks for the swift response.
I already did try it without the "/secure" part, and received the following string instead:
{"errorMessages":["Internal server error"],"errors":{}}
(Tried it again now, just to be sure - same result.)
Is this considered a progress? If so, what more is my code missing to make this work?
Do I have to provide the HttpClient object with my Jira username and password or something? If so, how?
Or is it something in the Json object that is not set properly?
Thanks,
Itai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Itai,
I'm not familiar with C#, so can't comment much on your code. But I'm sure that the URL must be:
Important points are:
I use cURL, and this is the JSON body that I use:
{
"fields": {
"project": {
"key": "SCRUM"
},
"summary": "creating sub-task",
"issuetype": {
"name": "Sub-task"
},
"parent": {
"key":"SCRUM-1"
}
}
}
Take note that, issue type must be Sub-task type, and Project Key must be the same as the key part of the Parent issue key.
You may want to refer to REST API 7.11.2 | issue-createIssue for more info.
I hope this helps.
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.