Hi Team,
while creating the issue through REST API, 'Team' field of JIRA Portfolio is not populating.
I am trying to update Team with Custom ID: customfield_10300.
your immediate help is highly appreciated
Thanks and Regards
Ramachandra Reddy
@G Ramachandra, can you show us the code you're using and the response from the server?
Hi @Steven F Behnke,
please find my code as below.
RestClient client = new RestClient("https://myproject.atlassian.net/rest/api/2");
RestRequest request = new RestRequest("issue/", Method.POST);
client.Authenticator = new HttpBasicAuthenticator(txtJIRAUN.Text, txtJIRAUP.Text);
createIssue(request, client);
private void createIssue(RestRequest request, RestClient client)
{
try
{
var issue = new Issue
{
fields =
new Fields
{
description = JiraDesc,
summary = _tfsTitle,
project = new Project { key = "ProjectName" },
issuetype = new IssueType { name = "IssueType" },
priority = new Priority { name = _priority },
customfield_10400 = _tfsID,
customfield_11201 = _custName,
customfield_11500 = _supportid,
customfield_11100 = new Customfield_11100 { value = _itemType },
customfield_10300 = "TestTeam",
}
};
request.RequestFormat = DataFormat.Json;
request.AddJsonBody(issue);
var res = client.Execute<Issue>(request);
if (res.StatusDescription == "Created")
{
_jiraKey = res.Data.key;
bg.ReportProgress(0, "Issue Created, Id: " + _jiraKey);
}
else
{
bg.ReportProgress(0, "Issue Not Created.");
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
public class Issue
{
public string id { get; set; }
public string key { get; set; }
public Fields fields { get; set; }
}
public class Fields
{
public Project project { get; set; }
public IssueType issuetype { get; set; }
public Priority priority { get; set; }
public string summary { get; set; }
public string description { get; set; }
public string customfield_10400 { get; set; }
public string customfield_11500 { get; set; }
public string customfield_11201 { get; set; }
public Customfield_11100 customfield_11100 { get; set; }
public string customfield_10300 { get; set; }
}
public class Project
{
public string id { get; set; }
public string key { get; set; }
}
public class IssueType
{
public string id { get; set; }
public string name { get; set; }
}
public class Priority
{
public string id { get; set; }
public string name { get; set; }
}
public class Customfield_11100
{
public string id { get; set; }
public string value { get; set; }
}
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.
Okay, the error clearly states the problem.
Team with ID 'TestTeam' could not be found
Can you create an issue in JIRA with the Team field set to TestTeam and perform an HTTP GET on /rest/api/2/issue/issueKey so you know what you need to send to JIRA?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
TestTeam is available in Team field in JIRA. I can select Team field as TestTeam in JIRA, It's working fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're not passing the right value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am passing TestTeam as below. (as mention in my code)
customfield_10300 = "TestTeam"
anything wrong here..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you perform an HTTP GET on an issue with it so you can see what value is stored? If the API isn't documented you should at least take a look at the GET shape and we can hope it's the same shape to POST/PUT.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JIRA won't let you create a new field during an issue creation/update. Those fields have to exist in JIRA already before you can update a value for that field on that issue.
There is a way to create new custom fields via REST as per https://docs.atlassian.com/jira/REST/server/#api/2/field
Alternatively you can also create the custom field with that name in the JIRA GUI as explained in Adding a Custom Field. Please note that when you first create a custom field in JIRA, you will probably have to reindex JIRA in order to then be able to use that new custom field.
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.