I am new in Jira integration using VBA with excel/access. I am trying to find macro enabled excel (xlsm) file from Jira and download. Let's say file name always starts with "abc". So far I am able to gather some codes from this community and got to the point that I can download a file from Jira. But two issues I am facing, those are,
- File is corrupted and not getting the actual content
- I still haven't figured out how to get the file name/url based on file name contains "abc"
Your valuable input will be much appreciated. Code I have got so far,
Sub GetFileFromJira()
Dim FileNum As Long
Dim FileData() As Byte
Dim WHTTP As Object
Dim mainUrl As String
Dim FileURL As String
Dim filePath As String
Dim strAuthenticate As String
mainUrl = "https://MyJiraUrl.com/"
FileURL = "https://MyJiraUrl.com/secure/attachment/1309245/test.xlsm"
filePath = "C:\Users\myId\Downloads\test.xlsm"
strAuthenticate = "start-url=%2F&user=" & "JiraUID" & "&password=" & "JiraPWD" & "&switch=Log+In"
Set WHTTP = CreateObject("WinHTTP.WinHTTPrequest.5.1")
WHTTP.Open "POST", mainUrl, False 'WHTTP.Open "POST", fileUrl, False
WHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
WHTTP.send strAuthenticate
WHTTP.Open "GET", FileURL, False
WHTTP.send
FileData = WHTTP.responseBody
Set WHTTP = Nothing
FileNum = FreeFile
Open filePath For Binary Access Write As #FileNum
Put #FileNum, 1, FileData
Close #FileNum
MsgBox "File has been downloaded!", vbInformation, "Success"
End Sub