Consulting

Results 1 to 4 of 4

Thread: Posting Issues to Jira using VBA

  1. #1

    Posting Issues to Jira using VBA

    Hi all,

    as the title suggests im looking to try and automate creating jira's but running into problems when trying to post.

    The authorization code seems to work as there's no failure when i use GET.

    the JSON seems to be ok.

    The error i recieve is "XSRF check failed" which upon research suggests im missing an additional authorisation step when posting data but i can't work out what's missing.

    Private JiraService                 As New MSXML2.XMLHTTP30
    Private arrData()                   As Byte
    
    
    Sub Test()
    
    
        Dim objRequest As Object
        Dim blnAsync As Boolean
        Dim strResponse As String
        Dim UserName, Password As String
        Dim sURL, strURL As String
        
        UserName = "XXXX"
        Password = "XXXXX"
    Call isAuthorized
    
    
        Set objRequest = CreateObject("MSXML2.XMLHTTP")
    
    
        
       sURL = "https://jira.XXX.com"
        
    m_sJSONString = json_Formatter()
        
        
        With objRequest
            .Open "POST", sURL & "/rest/api/2/issue/", False
            .setRequestHeader "Content-Type", "application/json"
            .setRequestHeader "Accept", "application/json"
            .setRequestHeader "Authorization", "Basic " & EncodeBase64
            .send m_sJSONString
            If .Status <> 401 Then
                m_sJSONString = .responseText
            Else
                m_sJSONString = "Error: Invalid Credentials!"
            End If
           
        End With
        
        
    
    
        Debug.Print m_sJSONString
    
    
    End Sub

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,704
    Location
    The only VBA errors(?) I see is that "Dim sURL, " makes sURL a Variant, which doesn't matter in VBA, and the 2 module level Variables are not used.

    Also, https://jira.XXX.com is not a valid Internet address.

    Place "Option Explicit" at the top of the Code Page. Debug >> Compile the code and fix any errors. Then Use F8 to step thru the code and fix any errors found that way.







    Finally, if you can't get jira working, take a look at FogBugz. Disclaimer, I am not a user of fogbugz, nor associated with them. I just admire Joel Spotsky.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,234
    .setRequestHeader "Authorization", "Basic " & EncodeBase64


    The variable EncodeBase64 has no content, nor is it declared.

    @SamT

    Previously you seemed a fan of Spolsky ?
    You changed your bets ?

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,704
    Location
    Sploky's outfit invented foxbugz
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •