Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Jira issue created through code not visible in Jira board

Edited

I am working on automating Jira ticket generation through code whenever a form submission fails. Though getting SuccessStatusCode from response, I am unable to view the created issue anywhere (Backlog or Active) in Jira board. Below is the code:

static async Task generateJiraTicket()
{
string jiraUrl = "<jiraUrl>";
string username = "<email>";
string apiToken = "<generated_token>";

// Create JSON payload for the new issue
string issueData = @"
{
""fields"": {
""project"": { ""key"": ""<Key>"" },
""summary"": ""Sample Jira Ticket for Forms"",
""description"": ""Form submission failed."",
""issuetype"": { ""name"": ""Bug"" }
}
}";

using (HttpClient client = new HttpClient())
{
client.BaseAddress = new Uri(jiraUrl);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{apiToken}")));

try
{
// Send a POST request to create the issue
HttpResponseMessage response = await client.PostAsync(jiraUrl, new StringContent(issueData, Encoding.UTF8, "application/json"));

if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine("Issue created successfully!");
Console.WriteLine($"Ticket URL: {response.Headers.Location}");
Console.WriteLine($"Response content: {responseBody}");
}
else
{
Console.WriteLine($"Failed to create issue. Status code: {response.StatusCode}");
string errorResponse = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Response content: {errorResponse}");
}
}catch (Exception ex)
{
Console.WriteLine($"Response content: {ex}");
}
}
}

 

 

Am I missing something? Can someone help on this?

1 answer

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 29, 2023

Hello @Shrikant Katagi 

Welcome to the Atlassian community.

Do you get the issue key for the created issue as part of the response?

Are you able to view the issue directly in Jira based on that key?

If so, have you confirmed that the issue you created actually matches the filter used for the board? And is the issue set to a Status that is mapped to a column in that board?

Hi @Trudy Claspill 

I am not getting the issue key in the response, so not able to view the issue directly in Jira based as well.

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 03, 2023

What response are you getting?

The issue was with the API token as this need to be authenticated by Jira admin team. 

Suggest an answer

Log in or Sign up to answer