Hi,
I am trying to logon to JIRA using VBA and access a predefined filter for issues and then export it as a JSON file.
I took help from old posts on this forum but so far no success in getting the output. The code runs smoothly with no error but doesn't do anything. Please help me out with it.
<Code>
Sub JIRA()
Dim oJiraAuth As MSXML2.ServerXMLHTTP60
Dim oJiraService As MSXML2.ServerXMLHTTP60
Dim JIRA_USER As String
Dim JIRA_PWD As String
Set oJiraAuth = New MSXML2.ServerXMLHTTP60
With oJiraAuth
.Open "POST", "https://jira.domainname.com/secure/Dashboard.jspa", False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.send " {""myusername"" : """ & JIRA_USER & """, ""mypassword"" : """ & JIRA_PWD & """}"
sOutput = .responseText
sCookie = "JSESSIONID=" & Mid(sOutput, 42, 32) & "; Path=/Jira"
End With
Set oJiraService = New MSXML2.ServerXMLHTTP60
With oJiraService
.Open "GET", "https://jira.domainname.com/issues/?filter=17906", False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "Authorization", "Basic " & EncodeBase64(JIRA_USER & ":" & JIRA_PWD)
.setRequestHeader "Set-Cookie", sCookie
.send
sOutput = .responseText
sStatus = .Status & " | " & .statusText
End With
Set oJiraService = Nothing
Set oJiraAuth = Nothing
End Sub
Private Function EncodeBase64(srcTxt As String) As String
Dim arrData() As Byte
arrData = StrConv(srcTxt, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument60
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument60
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.text
Set objNode = Nothing
Set objXML = Nothing
End Function
</Code>
Parth