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 = {
"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, options);
Logger.log(response);
}
But i'm getting an error
Request failed for.... returned code 405
What am i missing here? any idea why this won't work?
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}";
"method":"PUT",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you guys for your help!
using @Gregor Kasmann_Actonic 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
"method":"PUT",
And now it works!
Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is fetch working successfully, Im getting BAD Request error. Im trying to integration Google sheet online.
If possible pls share the code.
UrlFetchApp.fetch(url, options);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.