0

I'm trying to create a web form where I can dynamically create a JIRA Epic using whatever the user inputs. I'm relying on the Atlassian JIRA SDK Nuget package to do so.

Here's the function as it stands right now.

public ActionResult Create(string title, string description)
{
    Jira jiraConnection = Jira.CreateRestClient("https://xxxx.atlassian.net/", "username", "password");
    Issue issueMain = jiraConnection.CreateIssue("xxxx");
    issueMain.Type = "Epic";
    issueMain.Priority = "Major";
    issueMain.Summary = title;
    issueMain.Description = description;

    try
    {
        issueMain.SaveChanges();
    }
    catch (Exception ex)
    {
         MessageBox.Show(ex.InnerException.Message.ToString());
         return View("Contact");
    }

    return RedirectToAction("Index");            
}

I've come across a few different errors in trying to get the issue actually created, but the one currently plaguing me is this:

error CS0103: The name 'client' does not exist in the current context

I hit this error when I hit the issueMain.SaveChanges() line, and I don't know why, because I'm not instantiating a "client" variable anywhere in this function and I can't step into the SaveChanges function to see where it might be getting referenced within it.

When I check the inner exception, I see that I'm getting an Encountered a 401 - Unauthorized error while loading this page error, which I also don't understand, as I am providing the credentials I would usually use to log in to our JIRA site.

R. D.
  • 127
  • 2
  • 10

1 Answers1

0

I have found the link to the Atlassian Jira SDK documentation: https://bitbucket.org/farmas/atlassian.net-sdk/wiki/Home

It looks like you need to add the two propertiesType and Priority when creating the issue.

issueMain.Type = "Bug"; issueMain.Priority = "Major";

IceCode
  • 1,466
  • 13
  • 22
  • Thank you for finding this and letting me know. Adding in these two fields has resulted in me seeing a new error, which I have edited the post to include. – R. D. May 01 '19 at 16:32
  • You're welcome. You need to double check your credentials. It could be that you need to provide another username and password when using the Jira API in the code. – IceCode May 01 '19 at 17:54
  • This link can possibly help you: https://jira.atlassian.com/browse/ID-6351?_ga=2.90791514.1739902226.1556648262-2113641288.1556648262 – IceCode May 01 '19 at 18:04
  • 1
    I'll save that link for later. I ran the credentials issue past our administrator and he said he's planning on tabling this project for now, so I'm at an impasse as far as testing this issue any further. But since you were able to help me sort out my first issue, I'll go ahead and mark your answer as the correct one. – R. D. May 02 '19 at 12:14