I'm trying to edit an issue in JIRA through GAS. Looking at some other people code (for example - Using Google Apps Script to Post JSON Data) I came up with this code:
function myFunctionpostTest() {
var username = "username";
var password = "password";
var encCred = Utilities.base64Encode(username+":"+password);
var url = "https://<base_url>/rest/api/2/issue/";
var data = {"project":{ "key": "STUDIO-4499"},"summary": "create
issue.", "issuetype": {"name": "Bug"}} ;
var payload = JSON.stringify(data);
var headers = { "Accept":"application/json",
"Content-Type":"application/json",
"Authorization":"Basic " + encCred,
};
var options = { "method":"POST",
"contentType" : "application/json",
"headers": headers,
"payload" : payload
};
var response = UrlFetchApp.fetch(url, headers);
Logger.log(response);
}
The issue is that i'm keep getting an error:
Request failed for.... returned code 405
What am i missing? why this code is not working?
Please don't answer with cURL example since it is not relevant for my issue