Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update custom field (Assignee Group) value using REST API..

Deleted user March 1, 2020

Hi All,

We have a field "Assignee Group" has few options (Development, UAT,etc..)

This is a dropdown field and am trying to update this field using issue transition.

using this rest url :

https://abc.atlassian.net/rest/api/3/issue/{issue key}/transitions?expand=transitions.fields

pls find the below json for the same.

{
"update": {
},
"fields": {
"customfield_ID": { "value": "UAT" }
},
"transition": {
"id": "201"
}
}

But i am unable to update it and giving "The remote server returned an error: (400) Bad Request."

Can anyone give me some idea , what i am doing wrong in above ... 

And also pls guide me - can we do update custom field through issue transitions?

If not what is the possible options to update the custom field to Jira.

Thanks

Vishnu

 

1 answer

0 votes
DPKJ
Community Champion
March 1, 2020

@[deleted]  Can you please share full command with headers. CURL will also work.

It seems error is related with 'Accept' and 'Content-Type' headers, value of those should be 'application/json'

Deleted user March 2, 2020

Thanks for your reply. I am using C# .Net programming as mentioned below.

var req = HttpWebRequest)WebRequest.Create("https://abc.atlassian.net/rest/api/3/issue/{IssueKey}/transitions?expand=transitions.fields");


var authInfo = "JiraUName:APIToken";

authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));

req.Headers["Authorization"] = "Basic " + authInfo;

req.Method = "POST";

req.ContentType = "application/json";


var requestStream = req.GetRequestStream();

var encoding = new ASCIIEncoding();


int transitionID = 201;

string fileContent = File.ReadAllText(@"C:\JIRARESTAPIJSON\Working_JSON_JIRA\IssueTransition_AGroup.json");
fileContent = fileContent.Replace("{0}", transitionID.ToString());

fileContent = fileContent.Replace("{1}", "Fixed");

JObject json = JObject.Parse(fileContent);

var serialized = JsonConvert.SerializeObject(json);

var buffer = encoding.GetBytes(serialized);


requestStream.Write(buffer, 0, buffer.Length);

requestStream.Flush();

requestStream.Close();


HttpWebResponse response = req.GetResponse() as HttpWebResponse;

DPKJ
Community Champion
March 2, 2020

Let me validate this on my site and get back to you.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events