Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Adding a custom field value programatically

Josh Faulk April 17, 2012

I've have downloaded the Atlassian SDK. In my project I referenced the Atlassian.Jira.dll. I have a csharp .net application.

The goal is to populate (or update) a custom field value. The custom field has been created, but the issue may or may not have a value for this custom field and I need to update it (or add it if it doesn't already exist).

I have been able to successfully add a comment to the issue, but I cannot add a custom field value. I recieve the error:

Sequence contains no matching element.

The code looks like this:

using Atlassian.Jira;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
test();
}
public void test()
{
Jira r = new Jira("http://localhost:8080", "username", "password");
Issue issue = r.GetIssue("TEST-1");
issue.AddComment("test comment"); // This works!
// This renders error: Sequence contains no matching element.
issue.CustomFields.Add("customfield_10142", new string[] { "21" });
issue.SaveChanges();
}
}
Is there a way to do this? Is there a better way (REST)? Is there a REST push option?
Any help would be greatly appreciated.
Can I just do this via the database?

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2012

Another option (but not in active development) is SOAP. Import the WSDL and generate the wrapper classes using Visual Studio.

Josh Faulk April 23, 2012

Thank you. The REST information worked.

When using CURL in windows, remember that you have use escaped quotes inside the quoted data field.

0 votes
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2012

If you are on Jira 5 you can use REST. Check this tutorial: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Edit+issues

TAGS
AUG Leaders

Atlassian Community Events