Through C# I am trying to create Jira issue which has custom field "Selling Details" using Atlassian SDk
. Below is the code:
string username = "XXX";
string password = "XXX";
string url = "https://rajasekharjira.atlassian.net";
var settings = new JiraRestClientSettings()
{
EnableRequestTrace = true
};
settings.CustomFieldSerializers.Add("https://rajasekharjira.atlassian.net", new SingleObjectCustomFieldValueSerializer("Selling Details"));
var jira = Jira.CreateRestClient(url, username, password,settings);
var issue = jira.CreateIssue("GUID");
issue.Type = "Bug";
issue.Priority = "High";
issue.Summary = "Issue Summary";
issue.CustomFields["Selling Details"].Values[0] = "abc";
issue.SaveChanges();
public class SingleObjectCustomFieldValueSerializer : ICustomFieldValueSerializer
{
//public string[] FromJson(JToken json)
//{
// throw new NotImplementedException();
//}
//public JToken ToJson(string[] values)
//{
// throw new NotImplementedException();
//}
private readonly string _propertyName;
public SingleObjectCustomFieldValueSerializer(string propertyName)
{
this._propertyName = propertyName;
}
public string[] FromJson(JToken json)
{
return new string[1] { json[this._propertyName].ToString() };
}
public JToken ToJson(string[] values)
{
return new JObject(new JProperty(this._propertyName, values[0]));
}
}
i am getting error at: issue.CustomFields["Selling Details"].Values[0] = "abc";
So please let me know how to create the issue with custom field name
I had updated the code with Serializer but i am not getting the custom fields at issue.CustomFields["Selling Details"].Values[0] = "abc";