Public Function makeJiraCall(ByVal resourceUrl As String, ByVal strUserLogin As String, ByVal strAPIToken As String) As String
Dim xmlhttp As New MSXML2.XMLHTTP60
xmlhttp.Open "Get", resourceUrl, False
xmlhttp.setRequestHeader "Accept", "application/json"
xmlhttp.setRequestHeader "Content-Type", "application/json"
Dim encodedauth As String
encodedauth = EncodeBase64(strUserLogin & ":" & strAPIToken)
xmlhttp.setRequestHeader "Authorization", "Basic " & encodedauth
xmlhttp.send
MsgBox xmlhttp.Status
makeJiraCall = xmlhttp.responseText
End Function
What is wrong in this code??
When I use pythong, i get data in Response, but above call from vba gives me following:
{"expand":"projects","projects":[]}
HI Rahul,
I see that you are using VBA in order to try to make a REST API call to a Jira Cloud site. I suspect that what is happening here is that VBA is doing something differently here when it comes to base64 encoding your string than is done via python.
If the authorization was incorrectly passed here, it could explain why Jira would respond this way. That endpoint is open even to anonymous calls, but you will certainly get back different results when authenticated vs when anonymous.
However I am not sure what the correct syntax for doing this in VBA. Take a look at our page in Basic auth for REST APIs. We have noted that in some systems, like Windows, using powershell has to make sure that we are taking these strings in as a UTF8 encoding before it is encoded. Otherwise the encoding ends up differently many times. I have also come across cases where the base64 encoding can include a carriage return unexpectedly, like in this thread.
It might be worth just trying to get your script to echo out what the base64 encoded string is here. That might be one way to then compare that against what is expected to be when following our guide. If the encoded strings are different here then we can at least know that is the problem here.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.