You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm able to create new issues via API, but I'm receiving 404 returns on the following:
var jiraComment = message.getSubject();
var issueKey = matchedValue;
var url = "https://COMPANY.atlassian.net/rest/api/latest/issue/"+issueKey+"/comment";
var data = {
"body": {
"content": [
{
"content": [
{
"text": jiraComment,
"type": "text"
}
],
"type": "paragraph"
}
],
"type": "doc",
"version": 1
},
// "visibility": {
// "identifier": "Administrators",
// "type": "role",
// "value": "Administrators"
// }
};
var payload = JSON.stringify(data);
var headers =
{
"content-type": "application/json",
"Accept": "application/json",
"authorization": "Basic APIKEY"};
var options =
{
"content-type": "application/json",
"method": "POST",
"headers": headers,
"payload": payload
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
var dataAll = JSON.parse(response.getContentText());
var commentId = dataAll.id
Logger.log(commentId);
When I take the manually created url in my browser I'm able to return appropriate results.
I use the same APIKEY to create the jira, so I figured it should work here as well.
I was premature in accepting my own answer, the problem actually was in the generation of the authentication. For some reason the formatting used within the creation of the jiras is not acceptable in my environment for comments.
Was able to successfully use postman with same APIKEY and used the headers from that into the app script to allow the posting of comments.
Here's the correct snippet for future issues;
var jiraComment = message.getSubject();
var issueKey = matchedValue;
var url = "https://COMPANY.atlassian.net/rest/api/latest/issue/"+issueKey+"/comment";
var data = {
"body": jiraComment,
};
var payload = JSON.stringify(data);
var headers =
{
"content-type": "application/json",
"Accept": "application/json",
"authorization": "Basic APIKEY"
};
var options =
{
"content-type": "application/json",
"method": "POST",
"headers": headers,
"payload": payload
};
var response = UrlFetchApp.fetch(url, options);
// Logger.log(response.getContentText());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.