JIRA Transition using VBA

Sayan May 4, 2013

Hi,

I am trying to create an excel macro which will automatically transition the status of JIRA's as per user input in the excel sheet.

We are using JIRA 4.4.5 version. Could anyone please help me out with some code snippets or formats for the post query (for VBA) that i can use to achieve my goal.

I googled a bit and found that i can access available JIRA transition states using the below code:


Private JiraService As New MSXML2.XMLHTTP60
Private JiraAuth As New MSXML2.XMLHTTP60

1. Create the "Cookie"/ session:

With JiraAuth
.Open "POST", "https://YourJIRAAddress/jira/rest/auth/1/session", False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.send " {""username"" : ""user"", ""password"" : ""passwort""}"""
sErg = .responseText
sCookie = "JSESSIONID=" & Mid(sErg, 42, 32) & "; Path=/Jira" '*** Extract the Session-ID
End With

2. Get the issue (here TEST-150):

With JiraService
.Open "GET", "https://YourJIRAAddress/jira/rest/api/2.0.alpha1/issue/TEST-150/transition", False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "Set-Cookie", sCookie '*** see Create a "Cookie"

.send
sRestAntwort = .responseText
End With

Now, I want to post a transition change on the above JIRA. Please help with your inputs. Thank You.

2 answers

0 votes
Nick Gover March 10, 2015

Hello,

I am also attempting to connect, however I am using VBScript.  Java is not an option as this is for Quality Center and it uses VBScript to customize.

I'm trying to auth using basic.  below is my existing code, modified from @Sayan

 

Dim oXMLHTTP
Set oXMLHTTP = ObjectCreate("WinHttp.WinHttpRequest.5.1")
      
   oXMLHTTP.open "POST", "http://jira.myurl.com/jira/rest/auth/latest/session", false
   oXMLHTTP.setRequestHeader "Authorization", "Basic (Base64String)"
   oXMLHTTP.setRequestHeader "Content-Type", "application/json"
   oXMLHTTP.setRequestHeader "Accept", "application/json"
   oXMLHTTP.Send
   sErg = oXMLHTTP.response
   MsgBox "Results are: " & sErg
   Set sCookie = "JSESSIONID=" & Mid(sErg, 42, 32) & "; Path=/Jira"              '*** Extract the Session-ID
   MsgBox "Cookie: " & sCookie

 

I get back nothing in my Msgbox response, not even an error.  It seems strange, is there a way to build an authentication header through this method.

 

Thanks!

 

 

0 votes
codelab expert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2013
Sayan May 5, 2013

Hello Mathias,

Thank you for your reply. However, both the methods posted in the link above are using curl and java.

I am using VBA and these commands did not work there. I was wondering if I could send a POST request via WINHTTP for transitioning the status and if so, then the possible format of sending the POST request in. Thank you

PARAG MADPUWAR October 19, 2017

Hi Sayan,

Did you get the solution for this via VBA to get the transition?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events