I’m trying to transition a jira issue with content. At the moment I have this which works to transition the issue:
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), restUrl))
{
string base64Credentials = GetEncodedCredentials();
request.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64Credentials);
var requestBody = new
{
transition = new
{
id = "11"
}
};
}
var jsonRequestBody = Newtonsoft.Json.JsonConvert.SerializeObject(requestBody);
request.Content = new StringContent(jsonRequestBody);
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var response = await httpClient.SendAsync(request);
But when I try to add a field when transitioning this issue I get an “Status Code 400 - Bad Request” error. This field does exist when I transition manually.
// returns status code 400 - bad request
var requestBodyFull = new
{
transition = new
{
id = "11"
},
fields = new
{
customfield_18421 = "Yes",
}
};
I’ve also tried:
var jsonRequestBody = Newtonsoft.Json.JsonConvert.SerializeObject(@"{""transition"": {""id"":""11""},""fields"":{""customfield_18421"":""Yes""}}");
request.Content = new StringContent(jsonRequestBody);
request.Content = new StringContent(@"{""transition"":{""id"":""11""},""fields"":
{""customfield_18421"":""Yes""}}", Encoding.UTF8, "application/json")