Google apps script 将Google电子表格连接到Atlassian JIRA

Google apps script 将Google电子表格连接到Atlassian JIRA,google-apps-script,google-sheets,jira-rest-api,Google Apps Script,Google Sheets,Jira Rest Api,我想使用Google Apps脚本在Google电子表格中显示我的JIRA问题,但首先我需要与JIRA建立连接,因此我浏览了这些,结果发现可能存在相反的情况(JIRA连接到其他应用程序),因此,我想问,是否有一种方法可以将Google Sheets连接到JIRA,在这种情况下,如何获取身份验证令牌 从JIRA请求令牌: 代码.gs 请查找连接到JIRA的示例代码,并以Json加载的形式获取响应 function seachIssuesR(j_query, maxresult) { if (!j_

我想使用Google Apps脚本在Google电子表格中显示我的JIRA问题,但首先我需要与JIRA建立连接,因此我浏览了这些,结果发现可能存在相反的情况(JIRA连接到其他应用程序),因此,我想问,是否有一种方法可以将Google Sheets连接到JIRA,在这种情况下,如何获取身份验证令牌

从JIRA请求令牌:

代码.gs

请查找连接到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;
函数seachIssuesR(j_查询,maxresult){
if(!j_query){
msgBox(“空查询::”+j_查询);
}
变量url=”https://.jira.com/rest/api/2/search?jql=“+j_query+”&startAt=0&maxResults=“+maxresult;
Logger.log(url);
如果(!PropertiesService.getScriptProperties().getProperty(“摘要”)){
var userAndPassword=Browser.inputBox(“以User:Password.例如。javarohit@gmail.com:mypassword@123(注意:这将被base64编码并保存为电子表格上的属性)“,“Userid:Password”,Browser.Buttons.OK\u CANCEL);
var x=Utilities.base64Encode(userAndPassword);
PropertiesService.getScriptProperties().setProperty(“摘要”、“基本”+x);
}
var digestfull=PropertiesService.getScriptProperties().getProperty(“摘要”);
变量头={
“接受”:“应用程序/json”,
“内容类型”:“应用程序/json”,
“方法”:“获取”,
“标题”:{
“授权”:完全授权
},
“muteHttpExceptions”:true
};
var resp=UrlFetchApp.fetch(url、标题);
如果(响应getResponseCode()!=200){
msgBox(“检索url“+url+”:“+resp.getContentText()”的数据时出错);
返回“”;
}否则{
json=resp.getContentText();
}
pri_list=JSON.parse(JSON);
返回优先级列表;

}

要向JIRA发送HTTP请求,可以使用以下方法。从应用程序脚本,你可以轻松地将数据写入电子表格。谢谢你的回答,但我不知道你所说的基本URL是什么意思。我使用了我的Atlassian实例,响应为空。对不起,我对Atlassian一无所知。从应用程序脚本的角度回答。我查阅了Atlassian文档,但找不到基本url的解释。在得到JSON响应后,可以解析is并在Google工作表上设置值
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;