[英]Connecting Google spreadsheet to Atlassian JIRA
我想使用 Google Apps 腳本在 Google 電子表格中顯示我的 JIRA 問題,但首先我需要與 JIRA 建立連接,所以我瀏覽了這些教程后才發現相反是可能的(JIRA 連接到其他應用程序),因此我想問一下是否有辦法將 Google Sheets 連接到 JIRA,在這種情況下如何獲取身份驗證令牌?
從 JIRA 請求令牌:
function requestJIRA_Token() {
var baseUrl = 'Put Base URL to JIRA here';
var theUrl = baseUrl + "/plugins/servlet/oauth/request-token";
var response = UrlFetchApp.fetch(theUrl);
Logger.log('response: ' + response);
};
請查找示例代碼以連接到 JIRA 並以 Json 加載的形式獲取響應
function seachIssuesR(j_query, maxresult) {
if (!j_query) {
Browser.msgBox("Null Query :: " + j_query);
}
var url = "https://<jiraServerName>.jira.com/rest/api/2/search?jql=" + j_query + "&startAt=0&maxResults=" + maxresult;
Logger.log(url);
if (!PropertiesService.getScriptProperties().getProperty("digest")) {
var userAndPassword = Browser.inputBox("Enter your Jira On Demand User id and Password in the form User:Password. e.g. javarohit@gmail.com:mypassword@123 (Note: This will be base64 Encoded and saved as a property on the spreadsheet)", "Userid:Password", Browser.Buttons.OK_CANCEL);
var x = Utilities.base64Encode(userAndPassword);
PropertiesService.getScriptProperties().setProperty("digest", "Basic " + x);
}
var digestfull = PropertiesService.getScriptProperties().getProperty("digest");
var headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"method": "GET",
"headers": {
"Authorization": digestfull
},
"muteHttpExceptions": true
};
var resp = UrlFetchApp.fetch(url, headers);
if (resp.getResponseCode() != 200) {
Browser.msgBox("Error retrieving data for url" + url + ":" + resp.getContentText());
return "";
} else {
json = resp.getContentText();
}
pri_list = JSON.parse(json);
return pri_list;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.