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

upload attachment to JIRA via REST API,but attachment with chinese name shows like "???"

I have upload a attachment with Chinese name, but it shows like "*???*", I use VBA to do that as following code (everything can worked except filename display error):

And this attachment Excel have macro, so i changed header "Content-Type: application/", "StrConv(srcTxt, vbFromUnicode, 1033)", "1033"(en-us) i have try change to "2050"(zh-cn), but the attachment with macro can't be open.



Private Function sendAttachmentToJira(ByVal sPostData As String) As Boolean

Dim sFileDataStr As String
Const STR_BOUNDARY_U As String = "abc123-xyz123"
JiraSite = ""
JIRAuser = Sheet1.Range("B3").Value
JIRApassword = Sheet1.Range("B4").Value

sFileDataStr = "--" & STR_BOUNDARY_U & vbCrLf & _
"Content-Disposition: form-data; name=""file"";Filename = """ & Mid$(sPostData, InStrRev(sPostData, "\") + 1) & """" & vbCrLf & _
"Content-Type: application/" & vbCrLf & _
vbCrLf & getFileBytes(sPostData) & vbCrLf & "--" & _
'Content-Type: multipart/form-data

With JiraService
.Open "POST", JiraSite & "/rest/api/2/issue/" & issueKey & "/attachments", False
.setRequestHeader "X-Atlassian-Token", "nocheck"
.setRequestHeader "Content-Type", "multipart/form-data ; boundary=" & STR_BOUNDARY_U 'application/json
.setRequestHeader "Authorization", "Basic " & EncodeBase64(JIRAuser & ":" & JIRApassword)
' .SetRequestHeader "Set-Cookie", Token
.send stringToByteArray(sFileDataStr)
JIRAResponse = .responseText
If .Status = "200" Then sendAttachmentToJira = True
End With

If Left(JiraService.Status, 1) = "4" Then MsgBox removeBrackets(JIRAResponse), vbCritical, "Adding attachments failed...": sendAttachmentToJira = False

End Function

Private Function stringToByteArray(srcTxt As String) As Byte()
stringToByteArray = StrConv(srcTxt, vbFromUnicode, 1033)
End Function


1 answer

so....   no one else had the same problem? ...

Suggest an answer

Log in or Sign up to answer

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