Editing an issue via Google script and JSON

i'm trying to edit an existing through Google script.

I've researched and came up with this code:

function sendData() {
var username = "username";
var password = "password";
var encCred = Utilities.base64Encode(username+":"+password);

var url = "https://<base URL>/rest/api/2/issue/";
var data = { "fields": {"summary": "new summary edit"} };
var payload = JSON.stringify(data);

var headers = {
"Authorization":"Basic " + encCred,

var options = {
"contentType" : "application/json",
"headers": headers,
"payload" : payload
var response = UrlFetchApp.fetch(url, options);

But i'm getting an error

Request failed for.... returned code 405

What am i missing here? any idea why this won't work?

3 answers

1 accepted

0 votes
Answer accepted

To editing an issue you shoud use this REST: https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue

Pay attention to:

 var url = "https://<base URL>/rest/api/2/issue/{issueIdOrKey}";

Thanks, answer accepted


You use POST /rest/api/2/issue/. This REST function creates an issue, but you do not provide project and issue type. Your playload is wrong

Thank you guys for your help!

using @Gregor Kasmann reference, i've changed the data variable to 

{"update":{"summary":[{"set":"Bug in business logic"}]}}; 

the url to 

var url = "https://<base URL>/rest/api/2/issue/41335";

and changed the method in the options var to



And now it works! 

Thank you very much!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Jira

Updates to jira.atlassian.com give you visibility into what's coming in Jira Server and Data Center

Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...

551 views 1 14
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you