SOAP add attachment to existing issue VBA

Hi,

I am trying to add the attachment to an exisitng issue in JIRA using SOAP in VBA (Excel).

The following code crashes, "Putting data into SoapMapper byte failed".

As far as I know bytArray should be the variant array with elements defined as Byte, I don't know why it fails...

Public Sub AddJiraAttachment()
    
Dim token As Variant

Dim SoapClient
Set SoapClient = CreateObject("MSSOAP.SoapClient30")
SoapClient.mssoapinit ("https://jira_instance/rpc/soap/jirasoapservice-v2?wsdl")


token = SoapClient.LogIn(username, password)

If Err <> 0 Then
wscript.echo "initialization failed " + Err.description
End If

Dim added As Boolean
Dim fileName() As Variant

fileName = Array("test.xls")

Dim intFileNum As Integer
Dim bytRtnVal() As Byte
Dim bytArray() As Variant

intFileNum = FreeFile

Open "C:\test.xls" For Binary Access Read As intFileNum
        
    ReDim Preserve bytRtnVal(LOF(intFileNum) - 1)
    Get intFileNum, , bytRtnVal
    Close intFileNum
        
bytArray = Array(bytRtnVal) 


added = SoapClient.addAttachmentsToIssue(token, TICKET_KEY, fileName, bytArray)
    
    
End Sub

Does anybody know how should this array with elements defined as byte look like?

1 answer

IN java we use this code. Maybe this will help you?

// use the base64 call as its 10 times faster due to soap handling of byte arrays jiraSoapService.addBase64EncodedAttachmentsToIssue(authToken, issueKey, new String[]{filename}, new String[]{new String(Base64.encode(contents))});

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

779 views 2 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you