var args = {
"method":"PUT",
"headers":{
"Authorization": "Basic " + Utilities.base64Encode("email:token"),
"Content-Type":"application/json"
},
"body":"{"update":{"summary":[{"set":"Bug in business logic"}]}}"
}
"permissions": {
"EDIT_ISSUES": {
"id": "12",
"key": "EDIT_ISSUES",
"name": "Edit Issues",
"type": "PROJECT",
"description": "Ability to edit issues.",
"havePermission": true
}
}
function editIssue() {
try {
const DOMAIN = 'my domain';
const EMAIL = 'my email address';
const API_TOKEN = 'my token';
const ISSUE_KEY = 'my issue key or ID';
var authorization = `Basic ${Utilities.base64Encode(`${EMAIL}:${API_TOKEN}`)}`;
var bodyData = {
update:
{
summary: [
{
set: 'Bug in business logic 2'
}
]
}
};
var fetchArgs = {
method: 'PUT',
headers: {
'Authorization': authorization,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(bodyData)
}
var url = `https://${DOMAIN}.atlassian.net/rest/api/latest/issue/${ISSUE_KEY}`;
var resp = UrlFetchApp.fetch(url, fetchArgs);
var code = resp.getResponseCode();
Logger.log('Success!');
}
catch (e) {
Logger.log(`Edit issue failed. ${e}`);
}
}
body: in params is incorrect. Switching to payload: fixed the issue.
var fetchArgs = {
method: 'PUT',
headers: {
'Authorization': authorization,
'Accept': 'application/json',
'Content-Type': 'application/json'
},
payload:body:JSON.stringify(bodyData)
}
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.