Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

I am able to attach excel file in JIRA with UFT, but while opening from Jira, saying format is wrong

Pritha I'm New Here May 04, 2021

Function addJIRA_Attachment(sURL)
' MSGBOX sCookie
Const STR_BOUNDARY = "abc123-xyz123"
sPath ="C:/Users/PB/JiraTest.xlsx"
fileType = "binary"
fileName="JiraTest.xlsx"
base64Encoded = convertFileToBase64(sPath)
getFilebyte = GetFileBytes(sPath)
request = "--" & STR_BOUNDARY & vbCrLf
request = request & "Content-Disposition: form-data; name=""file""; filename=" & fileName & "" & vbCrLf
request = request & "Content-Type: application/octet-stream" & vbCrLf
request = request & "Content-Transfer-Encoding: base64" & vbCrLf & vbCrLf
request = request & getFilebyte & vbCrLf
request = request & "--"& STR_BOUNDARY&"--"


Set JiraService = CreateObject("MSXML2.XMLHTTP.6.0")
With JiraService
.Open "POST", sURL & "rest/api/2/issue/GTAUIAF-19/attachments", False
.setRequestHeader "X-Atlassian-Token:" , "nocheck"
'.Open "GET", sURL & "rest/api/2/attachment/meta", False
.setRequestHeader "Content-Type", "multipart/form-data; boundary=" & STR_BOUNDARY
' .setRequestHeader "Content-Length", Len(request)
' .setRequestHeader "Accept", "application/json"
.setRequestHeader "Set-Cookie", sCookie
.send Stream_StringToBinary(request)
' msgbox .status
msgbox .responseText
m_sJSONString = .responseText
If .Status <> 400 or .Status<>404 Then
m_sJSONString = .responseText
Else
m_sJSONString = "Check the json string or url or your user id and password"
End If
keyval = Split(m_sJSONString,",")
For k = 0 to Ubound(keyval)
If Instr(keyval(k),"""key"":""")>0 Then
strval = split(keyval(k),":")
curTestkey = Replace(strval(1),"""","")
End If
Next
End With

Set JiraService= Nothing
End Function

Function getJiraSessionId(sURL,sJIRAUserID,sJIRAPass)
Set JiraAuth = CreateObject("MSXML2.XMLHTTP.6.0")
With JiraAuth
.Open "POST", sURL & "rest/auth/1/session", False
.setRequestHeader "X-Atlassian-Token:" , "nocheck"
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.send " {""username"" : """& sJIRAUserID &""", ""password"" : """& JIRA_PWD &"""}"
sOutput = .responseText
sCookie = "JSESSIONID=" & Mid(sOutput, 42, 32) & "; Path=/Jira"
End With
End Function

Function GetFileBytes(fileName)
Dim objStream
sType="binary"
Set objStream = CreateObject("ADODB.Stream")
objStream.Type=1
objStream.Open
objStream.LoadFromFile fileName
getbinaryArray=objStream.Read 'read binary'
msgbox TypeName(getbinaryArray)
objStream.Close
GetFileBytes=SimpleBinaryToString(getbinaryArray)
Set objStream = Nothing
end function

Function SimpleBinaryToString(Binary)
Dim I, S
For I = 1 To LenB(Binary)
S = S & Chr(AscB(MidB(Binary, I, 1)))
Next
SimpleBinaryToString = S
msgbox SimpleBinaryToString
End Function

Function Stream_StringToBinary(Text)
Const adTypeText = 2
Const adTypeBinary = 1
Dim BinaryStream 'As New Stream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeText
BinaryStream.CharSet = "us-ascii"
BinaryStream.Open
BinaryStream.WriteText Text
BinaryStream.Position = 0
BinaryStream.Type = adTypeBinary
BinaryStream.Position = 0
Stream_StringToBinary = BinaryStream.Read
Set BinaryStream = Nothing
End Function

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

203 views 6 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you