Hi,
I have this working httpClient request which creates a Jira ticket.
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), restUrl))
{
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {base64Credentials}");
request.Content = new StringContent("{\"fields\":{\"project\":{\"id\":\"23100\",\"key\":\"Type\",\"name\":\"PPD Ticket\"},\"summary\":\"Sample Subject\",\"issuetype\":{\"name\":\"PPD Ticket\"},\"components\":[{\"name\":\"Test Name\"}],\"customfield_18563\":\"1.0.0\",\"customfield_18962\":{\"name\":\"location\"}}}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await httpClient.SendAsync(request);
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Response: {0}", responseBody);
}
}
However, if I try to this string so the subject comes from a variable I get the error: "Failed to update transition. Status code: BadRequest"
Response: {"errorMessages":[],"errors":{"summary":"Field 'summary' cannot be set. It is not on the appropriate screen, or unknown.","customfield_18563":"Field 'customfield_18563' cannot be set. It is not on the appropriate screen, or unknown.","components":"Field 'components' cannot be set. It is not on the appropriate screen, or unknown.","customfield_18962":"Field 'customfield_18962' cannot be set. It is not on the appropriate screen, or unknown."}}
String mysubject = "Test Subject";
request.Content = new StringContent("{\"fields\":{\"project\":{\"id\":\"23100\",\"key\":\"PPD\",\"name\":\"PPD Ticket\"},\"summary\":" + mysubject + ,\"issuetype\":{\"name\":\"PPD Ticket\"},\"components\":[{\"name\":\"Product\"}],\"customfield_18563\":\"1.0.0\",\"customfield_19129\":\"
http://jira\",\"customfield_18962\":{\"name\":\"text info\"}}}");