I'm trying to transition issues via the API using .NET but I'm consistently getting a 400 error back. I'm wondering if anyone can see anything obvious that I'm doing wrong?
Code:
string example = @"{
""id"": ""221""
}";
string ticketjson = JsonConvert.SerializeObject(example);
string postUrl = "https://myurl/rest/api/2/issue/" + issueKey + "/transitions";
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
client.BaseAddress = new System.Uri(postUrl);
byte[] cred = UTF8Encoding.UTF8.GetBytes("username:pwd");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
var content = new StringContent(ticketjson, Encoding.UTF8, "application/json");
var response = client.PostAsync(postUrl, content).Result;
if (response.IsSuccessStatusCode)
{
string result = response.Content.ReadAsStringAsync().Result;
return result;
}
else
{
unauth.Text = "There has been a problem submitting your comment. Please try again.";
return response.StatusCode.ToString();
}
The transition exists and when I go to the postUrl I can see it:
Any help would be appreciated!
Hi @HLH ,
as specified here https://docs.atlassian.com/software/jira/docs/api/REST/8.22.2/#issue-doTransition , error 400 means that there's no transition specified.
Please specify just transition id and not other values like name ,to ...
...
}, "transition": { "id": "5" },
...
Take a look to the provided example.
Fabio
Thanks for your response :)
I think that's what I'm doing? This is the code that I'm passing to it. Is this id the correct one? I'd assumed from the screenshot that I included that because it as top level it was the correct id to reference, but maybe not!
string example = @"{
""id"": ""221""
}";
I then convert it to json and pass it to the post:
string ticketjson = JsonConvert.SerializeObject(example);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please could you check, through the log file, request structure sent to JIRA?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, is it the atlassian-jira.log file? Sorry haven't used the log files much before!
I can find other rest api calls in there for /comment, but nothing for /transitions or the specific issue key so I might be in the wrong place!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
take a look to the <JIRA HOME Folder>/log/atlassian-jira.log file in order to figure out what is the error and to figure out if the call has correctly managed by JIRA
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.