两件事......(1)本周早些时候发布了一篇文章,其中有人在云中的搜索行为也发生了变化。您可能想要查找该帖子以了解它是如何解决的(我会在片刻找到它,如果我找到它,我会在这里添加链接)。他和你一样使用“api / 3”...文档说“api / 3”处于测试阶段。那么也许试试“api / 2”?
(2)我不知道这段代码是否有用......它访问REST API,但我正在进行的调用与你的调用有很大的不同。这违反了JIRA的内部部署版本(最新的代码)。我没有要测试的云实例。
呼叫登录/验证:
Const APIAuthPath = "/rest/auth/1/session" Sub Call_JIRALogin(pUserName, pPassword) Dim JIRASendString As String, JIRASendURL As String JIRASendURL = BaseURL1 & APIAuthPath JIRASendString = " {" JIRASendString = JIRASendString & Chr(34) & "username" & Chr(34) & ":" & Chr(34) & pUserName & Chr(34) JIRASendString = JIRASendString & "," JIRASendString = JIRASendString & Chr(34) & "password" & Chr(34) & ":" & Chr(34) & pPassword & Chr(34) JIRASendString = JIRASendString & "}" Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP") objHTTP.setOption 2, 13056 With objHTTP .Open "POST", JIRASendURL, False .setRequestHeader "Content-Type", "application/json" .setRequestHeader "Accept", "application/json" .send (JIRASendString) CResponse1 = .responseText cCookie1 = "JSESSIONID=" & Mid(CResponse1, 42, 32) & "; Path=/Jira" '*** Extract the Session-ID CStatus1 = .Status End With
后续电话:
Sub BBB_SingleIssue_Driver(inIssueId) Dim JIRASendURL CurrIssue = inIssueId JIRASendURL = BaseURL1 & "/rest/api/2/issue/" & CurrIssue With objHTTP .Open "GET", JIRASendURL, False .setRequestHeader "Set-Cookie", cCookie1 '*** see Create a "Cookie" .send CResponse1 = .responseText CStatus1 = .Status End With If CStatus1 <> 200 Then MsgBox ("Failed to retrieve issue " & CurrIssue & " status code : " & CStatus1) GlobalHttpStatus = CStatus1 GlobalHttpResponse = CResponse1 GlobalStep = "Retrieve Issue: " & CurrIssue GoTo SingleIssueErrOut End If ' handle a good response SingleIssueErrOut: ' handle an error End Sub
最终的解决方案是使用 基本认证 通过 Authorization 向JIRA的Cloud REST API发出请求时的标头:
Authorization
https://CLOUD_ID.atlassian.net/rest/api/3/API_METHOD
头:
'Authorization': 'Basic ZGFjcmVAb...', 'Accept': 'application/json'
将来将删除基本身份验证 根据API文档 ,所以这被视为一种临时解决方案。