Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,284
Community Members
 
Community Events
184
Community Groups

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

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
AUG Leaders

Atlassian Community Events