I've modified Fabiano's solution here to create Jira issues in Excel/VBA for the rows selected in a spreadsheet; it worked out well and I was able to create issues from Excel just fine.
Now I want to be able to modify the issues in Excel. So I tried the following, but it seems like it is not even accessing the URI. As you can see, the URI is varying each time because every row has different Jira issue information (for example, row 2 is for TEST-111, row 3 is for TEST-112, ....)
Sub updateIssue()
Dim id As String
Dim rng As Range
Dim rs As Long
Dim JiraService As New MSXML2.XMLHTTP60
Dim ResponseTxt As Variant
Dim Summary As Variant
Dim Description As Variant
Dim Project As Variant
Dim IssueType As Variant
Dim IssueData As Variant
Dim Path As Variant
Dim UN As Variant
Dim PW As Variant
Dim Assignee As Variant
Dim sEncbase64Auth As Variant
Dim IssueKey As Variant
Dim IssueAddress As Variant
Dim IssueURL As Variant
UN = Sheet2.Range("A4").Value
Pw = Sheet2.Range("A5").Value
For Each rng In Selection.Rows
rs = rng.Row
Summary = ActiveSheet.Cells(rs, 4).Value 'summary
Description = ActiveSheet.Cells(rs, 5).Value 'Description
IssueType = ActiveSheet.Cells(rs, 9).Value 'IssueType
Assignee = ActiveSheet.Cells(rs, 8).Value 'assignee
IssueKey = ActiveSheet.Cells(rs, 14).Value 'issue key# in the format of TEST-111
IssueAddress = """ + "https://your-domain.atlassian.net/jira/rest/api/latest/issue/" + IssueKey + """
IssueData = " { ""update"": {}, ""fields"" : { ""parent"" : { ""key"" : ""TEST"" }, ""summary"" : """ & _
Summary & """, ""description"" : """ & Description & """, , ""assignee"" : { ""name"" : """ & Assignee & """ }} } "
sEncbase64Auth = CommonFunction.EncodeBase64(UN & ":" & Pw)
ActiveSheet.Range("G6").Value = IssueData & " | Auth Basic: " & sEncbase64Auth
'Updating/editing issue
With JiraService
.Open "POST", IssueAddress, False
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Accept", "application/json"
.SetRequestHeader "X-Atlassian-Token", "nocheck"
.SetRequestHeader "Authorization", "Basic " & sEncbase64Auth
.Send (IssueData)
ResponseTxt = .ResponseText
End With
ActiveSheet.Cells(rs, 8).Value = ResponseTxt
Set JiraService = Nothing
Next
End Sub
' Module CommonFunction
Public Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.text
Set objNode = Nothing
Set objXML = Nothing
End Function
I think the parsing part is where it's causing the error, as I do not see ResponseTxt returning anything. How can I solve this?
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.