I\'m trying to write a VBA macro that would pass my credentails to an address and fetch some content (REST API for JIRA), but I\'m having some difficulties converting my cod
Use the "Authorization" request header. The “Authorization” request header requires an encrypted string for username and password.
.setRequestHeader "Authorization", "Basic " & EncodeBase64
So here JiraService
being an XMLHTTP object, something like this will authenticate, where EncodeBase64
is a function which returns encrypted string.
Public Function isAuthorized() As Boolean
With JiraService
.Open "POST", sURL & "/rest/api/2/issue/", False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "Authorization", "Basic " & EncodeBase64
.send ""
If .Status <> 401 Then
isAuthorized = True
Else
isAuthorized = False
End If
End With
Set JiraService = Nothing
End Function
You can check out a complete VBA example here