It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Create a Jira Issue from Google Sheet

Hi,

Im trying to write a script to create a Jira Issue, when a User fills out a GoogleForm

I keep getting the following error

 

Capture.PNG

 

here is my code

 

Capture.PNG

The fields Project, Summary, Description and Issue Type exist in my Workspace

Can anyone help me ?

thanks

Phil

2 answers

1 accepted

0 votes
Answer accepted

Hi @Phil Walburn,

POST URL seems wrong. It should be like "....../rest/api/2/issue".

Here is the link; https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-post

Tansu

Thanks @Tansu Akdeniz

that fixed the problem

Hi @Phil Walburn This is something I have just started looking at however my Apps Script knowledge is somewhat limited at the moment - is there anyway you would be willing to share your code?

Hi Phil, 

Can you share your brilliance, I'm struggling here because of the 401 error. can you share the code it will be much appreciated.

Thanks,

Kannan

Kannan,

try something like this

Phil

 

// Set the Jira Credentials
var username = "YOUR USER NAME"; // <=========================== Set your Username here
var password = "YOUR PASSWORD"; // <=========================== Set your Password here
var UserCredentials = "Basic " + Utilities.base64Encode(username + ":" + password);

var IssueURL = "https://YOUR JIRA URL GOES HERE/rest/api/2/issue"; // <=========================== Set your Jira URL here
var IssueData = {"fields":
{"project": { "key": "ProjectCode" }, // Set the Project
"summary": Summary, // Set the Summary
"description": Description, // Set the Description
"issuetype": {"name": "Enhancement"}, // Set the Enhancement
"priority": {"name": Priority}, // Set the Priority
"customfield_xxxxx" : { "value": "Fieldvaluegoeshere"}

"customfield_xxxxx" : { "value": "Fieldvaluegoeshere"}

}
};

// Call the Jira API
var payload = JSON.stringify(IssueData);

var headers = {"Accept":"application/json",
"Content-Type":"application/json",
"Authorization": UserCredentials,
"muteHttpExceptions": "True"
};

var options = {"method":"POST",
"headers": headers,
"payload" : payload
};

var response = UrlFetchApp.fetch(IssueURL, options);

// Parse the JSON response to use the Issue Key returned by the API in the email
var dataAll = JSON.parse(response.getContentText());
var issueKey = dataAll.key

}

Hi Phil, thanks much for the quick help, it works now.

Kannan

Hi Phil,

Is there a way, such that we can create sub-task for the created Jira ticket. Can you please help on this, I'm new to the scripting.

Kannan.

Any one know how to use the API method instead ? This one as been anounce as "phase out" starting July 2019... so it won't work very fast.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

303 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you