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
Highlighted

JIRA REST attachement txt VB Edited

Deleted user Nov 05, 2019

Hi,

I have found a lot of topic on this subject but i am still lose. I can't find a solution so i come here for your help.

This is my code in vb

 

************************************************************************************************

************************************************************************************************

Public Function jiraSendFile(user As String, password As String, id As String, fileToUpload As String)

Dim oRequest As Object
oRequest = New WinHttp.WinHttpRequest
Dim data As String
Dim response As String
Dim status As String
Dim url As String
'Dim File As String

Dim File As New StreamReader(fileToUpload)

 

 

*************************       LOGIN       *******************************************
data = "{""username"": """ & user & """,""password"": """ & password & """}"
url = "http://vld-jira:XXXX/rest/auth/1/session"
oRequest.Open("POST", url)
oRequest.setRequestHeader("Content-Type", "application/json")
oRequest.Send(data)
response = oRequest.ResponseText
status = oRequest.Status

Result.Text = "Corps : " & data & vbCrLf & "Status : " & status & vbCrLf & "Réponse : " & response
Result.Update()

 

*************************       SEND    *******************************************
'File = fileToUpload
url = "http://vld-jira:XXXX/rest/api/2/issue/" & id & "/attachments"
'oRequest.Open("POST", url, True)
oRequest.Open("POST", url)
'oRequest.setRequestHeader("Content-Type", "application/json")
oRequest.setRequestHeader("X-Atlassian-Token", "no-check")
'oRequest.setRequestHeader("Authorization", "Basic")
'oRequest.setRequestHeader("Content-Disposition", "form-data; name=""file""; filename=test.txt""")
'oRequest.setRequestHeader("Content-Type", "multipart/form-data; boundary=21b8f440a67b603ac60941ee")
'oRequest.setRequestHeader("Content-Type", "application/octet-stream")
oRequest.setRequestHeader("Content-Type", "application/txt")
'oRequest.setRequestHeader("Content-Disposition", File)
oRequest.Send(File)

 

*************************       Result       *******************************************

response = oRequest.ResponseText
status = oRequest.Status

Result.Text = Result.Text & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "Corps : " & data & vbCrLf & "Status : " & status & vbCrLf & "Réponse : " & response
Result.Update()
'MsgBox(test & vbCrLf & status & vbCrLf & vbCrLf & response)

File = Nothing
oRequest = Nothing

 

Return 0
End Function

 

 

I got 415 message status or when i got 200 status, nothing is up in my jira issue.

 

Thanks a lot for your help.

0 comments

Comment

Log in or Sign up to comment
TAGS

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