I have read numerous posts on this issue and have experimented with suggestions. Unfortunately, none of them has addressed my problem. I can pull ticket information using the same authorization. There is no issue there.
var args = {
"method":"PUT",
"headers":{
"Authorization": "Basic " + Utilities.base64Encode("email:token"),
"Content-Type":"application/json"
},
"body":"{"update":{"summary":[{"set":"Bug in business logic"}]}}"
}Exception: Request failed for https://my-domain.atlassian.net returned code 400. Truncated server response: {"errorMessages":["No content to map to Object due to end of input"]}
I am a site admin, and below is the result for my edit permission. What am I missing? Is there a different permission required for editing through the API?
"permissions": {
"EDIT_ISSUES": {
"id": "12",
"key": "EDIT_ISSUES",
"name": "Edit Issues",
"type": "PROJECT",
"description": "Ability to edit issues.",
"havePermission": true
}
}
I am sure there are posts on this subject that I have missed. A link to similar post would be greatly appreciated.Thank you.
Test helper:
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}`);
}
}